Skip to content
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

compiling a packed struct with a u0 causes the compiler to abort #1554

Closed
winksaville opened this issue Sep 18, 2018 · 0 comments
Closed

compiling a packed struct with a u0 causes the compiler to abort #1554

winksaville opened this issue Sep 18, 2018 · 0 comments
Labels
bug Observed behavior contradicts documented or intended behavior
Milestone

Comments

@winksaville
Copy link
Contributor

winksaville commented Sep 18, 2018

Command demonstrating abort:

$ zig test u0-packed-struct-fails.zig 
zig: ../src/analyze.cpp:499: ZigType* get_pointer_to_type_extra(CodeGen*, ZigType*, bool, bool, PtrLen, uint32_t, uint32_t, uint32_t): Assertion `byte_alignment == 0' failed.
Aborted (core dumped)

Code here and below:

const assert = @import("std").debug.assert;

// zig: ../src/analyze.cpp:499: ZigType* get_pointer_to_type_extra(CodeGen*, ZigType*, bool, bool, PtrLen, uint32_t, uint32_t, uint32_t): Assertion `byte_alignment == 0' failed.
// Aborted (core dumped)
test "u0-packed-struct-fails" {
    const S = packed struct { f0: u0, };
    var s = S { .f0 = 0, };
    assert(s.f0 == 0);
}
@andrewrk andrewrk added this to the 0.4.0 milestone Sep 18, 2018
@andrewrk andrewrk added the bug Observed behavior contradicts documented or intended behavior label Sep 18, 2018
winksaville added a commit to winksaville/zig-u0-tests that referenced this issue Sep 18, 2018
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

No branches or pull requests

2 participants