Menu

#3998 FATAL Compiler .. Error ... SDCCgenconstprop.cc line 1402

closed-fixed
other
5
3 days ago
2026-06-02
bbbbbr
No

SDCC nightly build with no GBDK patches:

sdcc -v
SDCC : mcs51/z80/z180/r2k/r2ka/r3ka/r4k/r5k/r6k/sm83/tlcs90/ez80/z80n/r800/ds390/pic16/pic14/TININative/ds400/hc08/s08/stm8/pdk13/pdk14/pdk15/mos6502/mos65c02/f8/f8l TD- 4.6.0 #16555 (Linux)

Getting the following compiler error:

sdcc_genconstprop_1402_compiler_error.c:10: error 9: FATAL Compiler Internal Error in file 'SDCCgenconstprop.cc' line number '1402' : code generator internal error 

Building with:

sdcc -msm83 -c sdcc_genconstprop_1402_compiler_error.c
sdcc -mz80 -c sdcc_genconstprop_1402_compiler_error.c
sdcc -mmos6502 -c sdcc_genconstprop_1402_compiler_error.c

Minimal example to reproduce:

unsigned char loadedCharacters[10];

void my_func_1(unsigned char a);

inline void my_func2(unsigned int a) {
    if (a < 256) {
        my_func_1((unsigned char)a);
    } else {
        my_func_1((unsigned char)a);
    }
}

void my_func3(void){    
    my_func2((unsigned int)loadedCharacters[1]);
}

Related

Bugs: #4001

Discussion

  • Philipp Klaus Krause

    Apparently, the call to computeDataFlow in line 3923 of SDCCopt.c optimizes out an IFX iCode resulting in an unreachable basic block. Much later, that block is the eliminated, but OP_USES for an iTemp still references an iCode in that basic block.

     
  • Philipp Klaus Krause

    • status: open --> pending-fixed
    • assigned_to: Philipp Klaus Krause
     
  • Philipp Klaus Krause

    Fixed in the next branch in [r16574].

     

    Related

    Commit: [r16574]

    • bbbbbr

      bbbbbr - 2026-06-04

      Thank you!

       
  • Philipp Klaus Krause

    Unfortunately, the fix caused a regression in diagnostics: [bugs:#4001].

     

    Related

    Bugs: #4001

    • Philipp Klaus Krause

      The change has been reverted in trunk (where next had been merged to after SDCC 4.6.0 RC1). I'll try to come up with a better fix in the next branch.

       

      Last edit: Philipp Klaus Krause 2026-06-06
      • bbbbbr

        bbbbbr - 2026-06-21

        Thanks for the update. We'll keep an eye on this and make a new build once there is a new version to test with.

         
  • Philipp Klaus Krause

    • status: pending-fixed --> open
     
  • Tony Pavlov

    Tony Pavlov - 2026-06-30

    any news on this, Philipp?

     
    • Philipp Klaus Krause

      No. I didn't find time for it around the SDCC 4.6.0 release. There have been bugs that I considered more important (since they resulted in bad code being generated), or that were easier to fix, and I've been busy. I hope I find time to look into this one on the weekend, or sometime next week.

       
  • Philipp Klaus Krause

    • status: open --> closed-fixed
     
  • Philipp Klaus Krause

    Fixed in [r16698].

     

    Related

    Commit: [r16698]

    • bbbbbr

      bbbbbr - 2026-07-12

      Looks good on our end, thank you!

       
    • bbbbbr

      bbbbbr - 3 days ago

      Was the following line accidentally left in the fix? Toxa noticed It appears to output icode information to files (<name>.dumpcustom0) in some cases</name>

        /* miscellaneous optimizations */
         miscOpt (ebbi->bbOrder, ebbi->count);
      -
      +dumpEbbsToFileExt (DUMP_CUSTOM0, ebbi);
      
       
      • Philipp Klaus Krause

        No. Fixed in [r16705].

         

        Related

        Commit: [r16705]

  • Philipp Klaus Krause

    Fixed in [r16698].
    Edit: this is an unintentional duplicate of the message on the original bugfix from a week ago.

     

    Related

    Commit: [r16698]


    Last edit: Philipp Klaus Krause 3 days ago
    • bbbbbr

      bbbbbr - 3 days ago

      Thanks! I see it in [r16705]

       

      Related

      Commit: [r16705]


Log in to post a comment.