: Sample code that reproduces the problem.
struct S { struct S { int x; } a; };
2: Exact command used to run SDCC on this sample code.
sdcc -mz80 --std=c2y --nostdinc -S nested-tag-definitions-sample.c -o output.asm
No headers are needed. -S stops at assembly generation.
3: SDCC version tested.
SDCC : mcs51/z80/z180/r2k/r2ka/r3ka/r4k/r5k/r6k/sm83/tlcs90/ez80/z80n/r800/ds390/TININative/ds400/hc08/s08/stm8/pdk13/pdk14/pdk15 TD- 4.6.4 #0 (Linux)
published under GNU General Public License (GPL)
Compiler was built from clean official SVN r16981 sources on Linux.
4: Observed and expected behaviour.
Two definitions of the same type with member lists must not be nested within
each other. SDCC terminates with signal 11 before producing a diagnostic for
the nested by-value structure and union cases. A nested definition followed by
a pointer member is instead silently accepted. Nested definitions with
different tags and an ordinary self-referential pointer member are valid
controls. The report covers a crash and a missing diagnostic in the same
prohibited nested-definition form.
WG14 N3886,
6.7.3.4 paragraph 1, specifies these constraints. A diagnostic is expected.
5: Additional checks.
Compiler Explorer: SDCC trunk and GCC 16.2 side by side.
Both panes use the sample above. SDCC uses -mz80 --std=c2y; GCC uses
-std=c2y -pedantic-errors -fsyntax-only. Checked 7 October 2026: SDCC
terminates with SIGSEGV (CE reports exit 139); GCC diagnoses it.
The following focused matrix used 19 C2Y configurations plus Z80 C23. Every valid 'control' was compiled without diagnostics. GCC 16.2 diagnosed every invalid case and accepted every 'control'.
| Case | Expected | SDCC Z80 C2Y |
|---|---|---|
nested-struct-tag.c |
Invalid | Signal 11; no diagnostic |
nested-union-tag.c |
Invalid | Signal 11; no diagnostic |
nested-struct-pointer.c |
Invalid | Accepted silently |
nested-different-tag-control.c |
Valid | Accepted silently |
recursive-pointer-control.c |
Valid | Accepted silently |
Configurations: MCS51 default/large/medium/stack-auto, DS390, Z80, Z180,
Rabbit 2000/4000, SM83, TLCS-90, HC08, S08, STM8 default/large, PDK13/14/15,
and eZ80. Translation/diagnostic checks only; no runtime result is claimed.
Implementation observation: The struct/union parser processes the nested member definition while its
enclosing definition is still under construction.
Please consider the attached candidate bug fix patch.