-
-
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
Compiler panic when allocating an enum with a single field #15424
Comments
I just installed a 0.11.0-dev compiler. It seems like the crash is fixed there, but the compiler error is still a bit confusing:
It contains no reference to where the error originates from |
My error, I forgot to insert |
Allocating zero-bit types ought to work okay, and should essentially just return |
it is not as trivial as just using I've been wondering whether it even makes sense to have an align of 0. An alignment of 1 mean you can store it in every position, alignment 2 means every second position, etc. But what does alignment 0 mean? Without being an expert at it, types with a size of 0 should work with alignment 1 too. |
There is a proposal for changing that #7221 |
Zig Version
0.10.1
Steps to Reproduce and Observed Behavior
results in
it can also be reproduced in main using another allocator, so it isn't just limited to the testing allocator. Try to allocate
void
results in the same thingExpected Behavior
The error probably comes from
@sizeOf(Enum)
being 0. That makes sense, because an enum with just one possibility can be optimized away.I expect it to at least throw a normal compiler error instead of just crashing. This could be if an enum has less than two possibilities or if we try to allocate a type with a size of 0.
The text was updated successfully, but these errors were encountered: