Undefined struct fields are initialized to 0 instead of 0xAA in debug mode (with llvm backend) #20095
Labels
backend-llvm
The LLVM backend outputs an LLVM IR Module.
bug
Observed behavior contradicts documented or intended behavior
Milestone
Uh oh!
There was an error while loading. Please reload this page.
Zig Version
0.13.0-dev.75+5c9eb4081
Steps to Reproduce and Observed Behavior
Note how only the last variant actually contains the desired 0xAA (170) bytes:
Expected Behavior
Setting things to undefined should set them to 0xAA in Debug mode, like it does with the x86 backend.
This makes some bugs easier to identify.
Consider for example an
ArrayListUnmanaged
that gets initialized toundefined
, like in #20085.Since it gets currently set to 0 in debug mode, the
deinit()
does not produce any errors, making it only possible to identify the issue in release.With 0xAA it would produce a runtime crash when attempting to free it and according to zig zen:
The text was updated successfully, but these errors were encountered: