-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorregressionIt 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.14.0
Steps to Reproduce and Observed Behavior
- Create a new Zig project (I've used
zig init). - Place the following minimal code into your
main.zig:
fn createVec(x: f32, y: f32, z: f32) [3]f32 {
return .{ x, y, z };
}
var camera = .{
.pos = createVec(0, 0, 0),
};
pub fn main() !void {
camera.pos = createVec(0, 1, 0);
}- Build and run the project using
zig build run.
Observed Behavior
The program terminates with a segmentation fault:
Segmentation fault at address 0xaaaaaaaaaaaaaaaa
aborting due to recursive panic
run
└─ run zig_seg_fault_anony_lit_struct failure
error: the following command terminated unexpectedly:
/Users/arielbenichou/personal/zig-seg-fault-anonymous-literal-struct/zig-out/bin/zig_seg_fault_anony_lit_struct
Build Summary: 3/5 steps succeeded; 1 failed
run transitive failure
└─ run zig_seg_fault_anony_lit_struct failure
error: the following build command failed with exit code 1:
/Users/arielbenichou/personal/zig-seg-fault-anonymous-literal-struct/.zig-cache/o/0bd88885df425ba4769286815bd940e7/build /Users/arielbenichou/.zvm/0.14.0/zig /Users/arielbenichou/.zvm/0.14.0/lib /Users/arielbenichou/personal/zig-seg-fault-anonymous-literal-struct /Users/arielbenichou/personal/zig-seg-fault-anonymous-literal-struct/.zig-cache /Users/arielbenichou/.cache/zig --seed 0x82075a23 -Z0d899954f16beb30 run
Expected Behavior
Now I understand that Anonymous Struct Literals create comptime fields that can't be modified.
But should it compile at all?
Metadata
Metadata
Assignees
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorregressionIt worked in a previous version of Zig, but stopped working.It worked in a previous version of Zig, but stopped working.