Compiler discards const stack variable declarations and generates segfaulting code #19011
Labels
backend-llvm
The LLVM backend outputs an LLVM IR Module.
bug
Observed behavior contradicts documented or intended behavior
miscompilation
The compiler reports success but produces semantically incorrect code.
Milestone
Zig Version
0.12.0-dev.2811+3cafb9655
Steps to Reproduce and Observed Behavior
I'm on Windows 10
The code pasted below will segfault on
try vertices.append(v0);
in one of the ArrayList grows. This seems to be related to parameter-reference-optimization because the code will pass the arguments by pointer, which will be freed when it's time to copy them. The strange thing here is that by changing the variable declarations fromconst
tovar
, the generated code is now correct and passes the arguments by value. There is also another workaround where we calltry vertices.appendSlice(&.{ v0, v1 });
This happens in both debug and release fastExpected Behavior
No segfault in the generated code
The text was updated successfully, but these errors were encountered: