authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2024-05-21 19:51:08+03:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2024-05-21 19:52:25+03:00
logf776e70c3967da637d5488b6a8efaa8377680208
tree1cd5595095f7c404ea38f22ce39b255ccd0b7aca
parent167854c19c8072270187b91314a5481363af4e12

llvm: fix lowering of packed structs with optional pointers

Closes #20022

2 files changed, 8 insertions(+), 0 deletions(-)

src/codegen/llvm.zig+1
......@@ -3775,6 +3775,7 @@ pub const Object = struct {
37753775 .float,
37763776 .enum_tag,
37773777 => {},
3778 .opt => {}, // pointer like optional expected
37783779 else => unreachable,
37793780 }
37803781 const bits = ty.bitSize(mod);
test/behavior/packed-struct.zig+7
......@@ -1304,3 +1304,10 @@ test "2-byte packed struct argument in C calling convention" {
13041304 try S.bar(s);
13051305 }
13061306}
1307
1308test "packed struct contains optional pointer" {
1309 const foo: packed struct {
1310 a: ?*@This() = null,
1311 } = .{};
1312 try expect(foo.a == null);
1313}