Menu

#3175 segfault when using comma operator with inline functions

closed-fixed
None
other
5
2021-06-30
2021-02-04
Tony Pavlov
No
typedef struct OAM_item_t {
    char y, x;  //< X, Y Coordinates of the sprite on screen
    char tile;  //< Sprite tile number
    char prop;  //< OAM Property Flags
} OAM_item_t;


volatile struct OAM_item_t shadow_OAM[40];

inline void set_sprite_tile(char nb, char tile) {
    shadow_OAM[nb].tile=tile;
}

void main(void) {
  set_sprite_tile(0, 1), set_sprite_tile(0, 1);
}

error:

sdcc -mgbz80 --asm=rgbds --codeseg ROMX --no-optsdcc-in-asm --no-std-crt0 --fsigned-char -I libc/include -S -o testb.asm testb.c
testb.c:17: error 9: FATAL Compiler Internal Error in file '/home/sdcc-builder/build/sdcc-build/orig/sdcc/src/SDCCicode.c' line number '815' : code generator internal error
Contact Author with source code
Caught signal 11: SIGSEGV 

version:

SDCC : mcs51/z80/z180/r2k/r2ka/r3ka/gbz80/tlcs90/ez80_z80/z80n/ds390/pic16/pic14/TININative/ds400/hc08/s08/stm8/pdk13/pdk14/pdk15 4.0.7 #12016 (MINGW64)

Discussion

  • Benedikt Freisen

    The error means that something calls operandType (const operand *op) with a null pointer. Maybe this saves the next person that looks at it two minutes of work.

     
  • Erik Petrich

    Erik Petrich - 2021-06-30
    • status: open --> closed-fixed
    • assigned_to: Erik Petrich
     
  • Erik Petrich

    Erik Petrich - 2021-06-30

    Interestingly, functions with a void return type must actually return something of type void so the result of the comma operator will correctly also have type void.
    Fixed in [r12517]

     

Log in to post a comment.