-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Zig segfaults when initializing a tuple with double anonymous struct .{.{}}
#18972
Comments
The issue (as I see it) is that the code would be instantiating an empty union, which is an uninstantiable (" The compiler crashing is a bug however, as you've stated this should trigger a compile error - thank you for reporting! |
I don't think it is about empty unions. Here is what segfaults as well: pub fn main() !void {
const val: struct {
union { field: bool },
} = .{.{}};
_ = val;
} |
You're right, that's a different bug then. |
|
Zig Version
0.12.0-dev.2790+fc7dd3e28
Steps to Reproduce and Observed Behavior
Zig segfaults immediately when compiles the following code:
Running the example gives:
Possibly related to or a duplicate of: #9284 and #17349
Expected Behavior
There should be an error message or successful compilation.
Update
First, I thought it is about using double anonymous struct/enum literals. However, I think it is just about initializing unions inside a tuple. Here are some crashing examples:
Non-empty unions also cause the compiler to crash:
The text was updated successfully, but these errors were encountered: