Menu ▾ ▴

#4084 No diagnostic when the first operand of ?: has struct type

open
nobody
None
Front-end
5
21 hours ago
2026-09-27
No

1: Sample code that reproduces the problem.

struct aggregate { int member; } object;
int test(void) { return object ? 1 : 2; /* ERROR */ }

2: Exact command used to run SDCC on this sample code
./bin/sdcc -c bug.c

3: SDCC version tested

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/huc6280/f8/f8l TD- 4.6.2 #0 (macOS ARM64)

4: Copy of the error message or incorrect output, or a clear description of the observed versus expected behavior.

The function definition violates a constraint. According to the ISO C standard, all constraint violations must be diagnosed. Clang, GCC and TCC report the constraint violation but SDCC does not. See https://godbolt.org/z/GM86bhsj5

Related

Bugs: #4129

Discussion

  • Christopher Bazley

    Here's a candidate fix against baseline f68fca8a4368ece9fe93b21f2e0341282b104359, containing the corresponding valdiag test. The combined valdiag testing passed on 19 tested ports; the full test-ucz80 run was not completed.

     

    Last edit: Christopher Bazley 4 days ago
  • Christopher Bazley

    Christopher Bazley - 21 hours ago

    This is duplicated by [bugs:#4129].

     

    Related

    Bugs: #4129


Log in to post a comment.