Skip to content

Compiler assertion when specifying alignment on empty struct #2957

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

Closed
hryx opened this issue Jul 27, 2019 · 2 comments · Fixed by #3166
Closed

Compiler assertion when specifying alignment on empty struct #2957

hryx opened this issue Jul 27, 2019 · 2 comments · Fixed by #3166
Labels
bug Observed behavior contradicts documented or intended behavior
Milestone

Comments

@hryx
Copy link
Contributor

hryx commented Jul 27, 2019

I have no experience with alignment yet, so I don't know what's special about this or how to look into it. Apologies if it's a duplicate.

pub fn main() void {
    var s: struct {} align(4) = undefined;
}
Assertion failed. This is a bug in the Zig compiler.
???:?:?: 0x55d02c43a2c9 in ??? (???)
...
@fengb
Copy link
Contributor

fengb commented Jul 27, 2019

I'm pretty sure 0 sized variables can't have memory representation so it also cannot be aligned.

@hryx
Copy link
Contributor Author

hryx commented Jul 27, 2019

Makes sense, I figured my example was probably invalid. This can track the compiler bug at least.

@andrewrk andrewrk added the bug Observed behavior contradicts documented or intended behavior label Jul 29, 2019
@andrewrk andrewrk added this to the 0.5.0 milestone Jul 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants