llvm: revert bad array access optimization

Closes #18723
This commit is contained in:
Veikka Tuominen
2024-01-29 09:46:12 +02:00
committed by Andrew Kelley
parent 9c7fa358c1
commit f93a36c091
2 changed files with 13 additions and 28 deletions

View File

@@ -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();
}