1: Sample code that reproduces the problem.
constexpr float object = 16777217L;
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. A diagnostic is required by
WG14 N3886,
6.7.2 paragraph 5.
A constexpr initialiser value must be exactly representable in the corresponding target type without a change of value. SDCC uses a 32-bit float with 24 bits of binary precision. The integer value 16777217 cannot be represented exactly. SDCC accepts it both for a float object and for a float member; 16777216 is a valid exact valid case.
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-exact-float-control.c |
Valid | Accepted silently on all five targets |
constexpr-exact-member-control.c |
Valid | Accepted silently on all five targets |
constexpr-inexact-float.c |
Diagnostic required | Accepted silently on all five targets |
constexpr-inexact-member.c |
Diagnostic required | Accepted silently on all five targets |
Please consider the attached candidate bug fix patch authored with Codex.