Skip to content

Instantly share code, notes, and snippets.

@winksaville
Last active September 18, 2018 17:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save winksaville/8758b59384c7ce0c3604d8b4f708929c to your computer and use it in GitHub Desktop.
Save winksaville/8758b59384c7ce0c3604d8b4f708929c to your computer and use it in GitHub Desktop.
compiler aborts when there is a u0 field in a packed struct
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);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment