- Category: other --> Front-end
1: Sample code that reproduces the problem.
extern constexpr int object = 1;
2: Exact command used to run SDCC on this sample code.
sdcc -mz80 --std=c2y --nostdinc -S bug.c -o bug.asm
3: SDCC version tested.
SDCC 4.6.4 #17064 (Linux), tested 21 October 2026.
4: Observed and expected behaviour.
SDCC exits successfully and emits no diagnostic.
WG14 N3886,
6.7.2 paragraph 2, specifies the constraint violated by the sample.
The permitted storage-class combinations do not include extern with constexpr. Either ordering is silently accepted. Plain constexpr and static constexpr are valid cases. An initialiser makes the extern declaration a definition; that does not make the storage-class combination valid.
5: Additional checks.
The sample is silently accepted on Z80, MCS51 default, STM8 default, PDK14 and MOS65C02 in C2Y mode. These are translation and diagnostic checks; no runtime result is claimed.
Compiler Explorer: SDCC 4.6.0, SDCC trunk and GCC 16.2. All three panes use the sample above. The saved source, compiler selections and options were round-trip verified on 21 October 2026. Both SDCC panes use -mz80 --std=c2y; GCC uses -std=c2y -pedantic-errors -fsyntax-only. The public trunk build is r17013, distinct from the local r17064 retest.
| CE compiler | Observed result |
|---|---|
| SDCC 4.6.0 | Accepted silently |
| SDCC trunk r17013 | Accepted silently |
| GCC 16.2 | Rejected with diagnostics |
| Case | Expected | Current SDCC results |
|---|---|---|
constexpr-control.c |
Valid | Accepted silently on all five targets |
constexpr-extern.c |
Diagnostic required | Accepted silently on all five targets |
constexpr-static-control.c |
Valid | Accepted silently on all five targets |
extern-constexpr.c |
Diagnostic required | Accepted silently on all five targets |