From f93a36c091a151ed02602d2f330f7206eb9f95a3 Mon Sep 17 00:00:00 2001 From: Veikka Tuominen Date: Mon, 29 Jan 2024 09:46:12 +0200 Subject: llvm: revert bad array access optimization Closes #18723 --- test/behavior/basic.zig | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test/behavior/basic.zig') 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(); +} -- cgit v1.2.3