LLVM backend miscompilation, assigning packed struct pointer to global zeroes it
bug
### Zig Version
0.15.1
### Steps to Reproduce and Observed Behavior
I have a packed struct that contains a pointer. If I assign it to a new value, and that value points to a global, the LLVM backend zeroes the struct. The x64 backend compiles it correctly.
### Expected Behavior
I expected this test to pass on both backends:
```zig
var global_var: u32 = 10;
const PackedStruct = packed struct {
ptr: *u32,
};
test "foo" {
const instance: PackedStruct = .{ .ptr = &global_var };
var copy: PackedStruct = undefined;
copy = instance;
try std.testing.expectEqual(instance.ptr, copy.ptr);
}
```
But I get this output on the LLVM backend:
```zig
error: 'ext.tag.test.foo' failed: expected u32@1127248, found u32@0
```
关闭于 2025-11-25 2 条评论