C Backend Miscompiles With static void const
Incomplete Type
#22364
Labels
backend-c
The C backend (CBE) outputs C source code.
bug
Observed behavior contradicts documented or intended behavior
miscompilation
The compiler reports success but produces semantically incorrect code.
Milestone
Zig Version
0.14.0-dev.2384+cbc05e0b1
Steps to Reproduce and Observed Behavior
OS: Windows 10
When using the C-backend I run into an issue of a
static void const
type being generated, which leads to a compile error in GCC. A minimized example can be found on my branch: https://github.com/Bud-ro/zig-pub-sub/tree/error_reproduction, code pasted for convenience:When this is compiled with
zig build-exe -target x86_64-linux-gnu -OReleaseSmall -ofmt=c ./src/example_repro.zig -femit-bin=".\zig-out\bin\main.c"
and put through GCC (inside WSL, this was necessary because the C-backend doesn't support Windows to my knowledge) the output is the following:Removing that
ErdOwner
enum field and definition leads to a C file free of this empty type.Expected Behavior
Expected behavior is for types only used at
comptime
to not have code generation in the C-backend. Further, it is expected that no incomplete types would be generated by the C-backend.The text was updated successfully, but these errors were encountered: