-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
backend-llvmThe LLVM backend outputs an LLVM IR Module.The LLVM backend outputs an LLVM IR Module.bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorfrontendTokenization, parsing, AstGen, Sema, and Liveness.Tokenization, parsing, AstGen, Sema, and Liveness.regressionIt worked in a previous version of Zig, but stopped working.It worked in a previous version of Zig, but stopped working.
Milestone
Description
Zig Version
0.10.0-dev.4217+9d8cdb855
Steps to Reproduce
const std = @import("std");
const expect = std.testing.expect;
const U = union(enum) {
array: [10]u32,
other: u32,
};
test {
var x = U{ .array = undefined };
x.array[1] = 0;
const a = x.array;
x.array[1] = 15;
try expect(a[1] == 0);
}In -O Debug, the .load of the overall union object is not elided because of an intervening union tag check, so this bug does not manifest. However, that elision would actually be correct and is applied in .ReleaseFast mode.
The incorrect part is that .struct_field_val returns a pointer to the union field without doing a side effect check like what's done in airLoad
Expected Behavior
Test should pass (like in stage1).
Actual Behavior
$ zig test test.zig -O ReleaseFast
Test [1/1] test_0... FAIL (TestUnexpectedResult)
0 passed; 0 skipped; 1 failed.
error: the following test command failed with exit code 1:
/Users/toadman667/repos/zig/zig-cache/o/8907a365291a8522093c111f26d53494/testReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
backend-llvmThe LLVM backend outputs an LLVM IR Module.The LLVM backend outputs an LLVM IR Module.bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorfrontendTokenization, parsing, AstGen, Sema, and Liveness.Tokenization, parsing, AstGen, Sema, and Liveness.regressionIt worked in a previous version of Zig, but stopped working.It worked in a previous version of Zig, but stopped working.