diff options
| author | Veikka Tuominen <git@vexu.eu> | 2024-01-29 09:46:12 +0200 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2024-01-29 08:43:27 -0800 |
| commit | f93a36c091a151ed02602d2f330f7206eb9f95a3 (patch) | |
| tree | 1e3e822ff0e9cc5c6b55b47039fa9545fa04349e /test/behavior/basic.zig | |
| parent | 9c7fa358c11bbb49f2e624cf81c5003e39fbcd92 (diff) | |
| download | zig-f93a36c091a151ed02602d2f330f7206eb9f95a3.tar.gz zig-f93a36c091a151ed02602d2f330f7206eb9f95a3.zip | |
llvm: revert bad array access optimization
Closes #18723
Diffstat (limited to 'test/behavior/basic.zig')
| -rw-r--r-- | test/behavior/basic.zig | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/behavior/basic.zig b/test/behavior/basic.zig index dc04a5b45c..42792f4aca 100644 --- a/test/behavior/basic.zig +++ b/test/behavior/basic.zig @@ -1400,3 +1400,16 @@ test "allocation and looping over 3-byte integer" { try expect(x[0] == 0x00); try expect(x[1] == 0x00); } + +test "loading array from struct is not optimized away" { + const S = struct { + arr: [1]u32 = .{0}, + fn doTheTest(self: *@This()) !void { + const o = self.arr; + self.arr[0] = 1; + try expect(o[0] == 0); + } + }; + var s = S{}; + try s.doTheTest(); +} |
