Commit f776e70c39

Veikka Tuominen <git@vexu.eu>
2024-05-21 18:51:08
llvm: fix lowering of packed structs with optional pointers
Closes #20022
1 parent 167854c
Changed files (2)
src
codegen
test
src/codegen/llvm.zig
@@ -3775,6 +3775,7 @@ pub const Object = struct {
             .float,
             .enum_tag,
             => {},
+            .opt => {}, // pointer like optional expected
             else => unreachable,
         }
         const bits = ty.bitSize(mod);
test/behavior/packed-struct.zig
@@ -1304,3 +1304,10 @@ test "2-byte packed struct argument in C calling convention" {
         try S.bar(s);
     }
 }
+
+test "packed struct contains optional pointer" {
+    const foo: packed struct {
+        a: ?*@This() = null,
+    } = .{};
+    try expect(foo.a == null);
+}