-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
anon union initialization at runtime reaches unreachable code #19966
Labels
bug
Observed behavior contradicts documented or intended behavior
Comments
lun-4
added
the
bug
Observed behavior contradicts documented or intended behavior
label
May 14, 2024
To show that this is specific to anon initialization, this snippet reproduces the issue, but if you replace the anon init with the reference to the type, it compiles: const Union = union(enum) {
not_found: void,
};
var cached_graphics_magick: Union = undefined;
pub fn main() void {
cached_graphics_magick = .{ .not_found = {} }; // crashes, comment to compile
cached_graphics_magick = Union{ .not_found = {} }; // compiles without issue
} |
duplicate of #19832 |
oops. thanks! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Zig Version
0.13.0-dev.207+e2ec54bb3
Steps to Reproduce and Observed Behavior
The original code that caused this crash is larger, but I reduced it to this which reproduces the same panic stack trace:
Leads to this crash:
Expected Behavior
This code compiles on zig 0.11, but stopped working on 0.12. These results are using the Release builds of zig, rather than Debug (Observed Behavior section uses 0.13-dev on Debug mode as shown before):
The text was updated successfully, but these errors were encountered: