diff options
| author | Veikka Tuominen <git@vexu.eu> | 2022-08-22 10:17:58 +0300 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2022-08-22 11:16:36 +0300 |
| commit | b0bcd4add29b6fbbe2bbc22719703d3c81ed594b (patch) | |
| tree | 8604903fa493cc8f9f328ffcefcd2bcea2f8b8bb /test | |
| parent | 74c7782c6083d398a4f0f126a4597c605d5223cd (diff) | |
| download | zig-b0bcd4add29b6fbbe2bbc22719703d3c81ed594b.tar.gz zig-b0bcd4add29b6fbbe2bbc22719703d3c81ed594b.zip | |
Sema: allow optional pointers in packed structs
Closes #12572
Diffstat (limited to 'test')
| -rw-r--r-- | test/behavior/packed-struct.zig | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/behavior/packed-struct.zig b/test/behavior/packed-struct.zig index 8c34f5741b..540914bd25 100644 --- a/test/behavior/packed-struct.zig +++ b/test/behavior/packed-struct.zig @@ -434,3 +434,15 @@ test "@ptrToInt on a packed struct field" { }; try expect(@ptrToInt(&S.p0.z) - @ptrToInt(&S.p0.x) == 2); } + +test "optional pointer in packed struct" { + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; + if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; + if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; + if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; + + const T = packed struct { ptr: ?*const u8 }; + var n: u8 = 0; + const x = T{ .ptr = &n }; + try expect(x.ptr.? == &n); +} |
