Analysis Affected code Crash site (STM8): src/stm8/gen.c genReturn() takes the scalar path because IS_STRUCT (operandType (IC_LEFT (ic))) is false for the pointer-typed operand aopRet() returns NULL for struct-returning functions genMove(): wassert (result) fires (line 2773 in 4.6.0 #16555), then genMove_o() dereferences NULL → SIGSEGV Crash site (Z80): src/z80/gen.c, line 6373 in 4.6.0 #16555 (not analysed, presumably the same pattern) Root cause: src/SDCCopt.c, replaceRegEqv(), the "Convert struct...
Possibly related: with SDCC 4.6.0 the same crash pattern (STM8 gen.c:2773, Z80 gen.c:6373, MCS51 OK) also occurs without a conditional operator, e.g. return w.in; or return *p; for a struct type. Reported separately as #4250, in case the candidate fix here doesn’t cover those paths.
[STM8, Z80] FATAL internal error in gen.c when returning a struct member or dereferenced struct pointer (no conditional operator)