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:
genc_1282_compiler_error.c:40: error 9: FATAL Compiler Internal Error in file 'gen.c' line number '1282' : code generator internal error
Building with:
sdcc -msm83 -c genc_1282_compiler_error.c
sdcc -mz80 -c genc_1282_compiler_error.c
Minimal example to reproduce:
If the (unsigned int) cast for the BANKREF_EXTERN() macro is removed then the compiler error goes away. I was adding it to temporarily suppress the (new or newly sensitive in sdcc 4.6.0) warning 322 that gets issued converting the pointer to
warning 322: Cast of pointer to integer type that cannot represent all values of the pointer type from type 'void __code* fixed' to type 'unsigned-char fixed'
The same error is showing up other code that isn't exactly like this, but this was easier to reduce.
#define BANK(VARNAME) ( (unsigned char) ((unsigned int)(& __bank_ ## VARNAME)) )
#define BANKREF_EXTERN(VARNAME) extern const void __bank_ ## VARNAME;
#define __REG extern volatile __sfr
#define __BYTE_REG extern volatile unsigned char
#define SWITCH_ROM(b) (_current_bank = (b), rROMB0 = (b))
__BYTE_REG rROMB0;
__REG _current_bank;
extern const unsigned char some_const_var_4;
BANKREF_EXTERN(some_const_var_4)
void main(void)
{
unsigned char _saved_bank;
_saved_bank = _current_bank;
SWITCH_ROM(BANK(some_const_var_4));
// ...
SWITCH_ROM(_saved_bank);
}
I can reproduce the issue on my Debian GNU/Linux testing system for both current trunk and next.
Fixed in the next branch in [r16572].
Related
Commit: [r16572]
Thank you!