-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Packed struct bug. #20938
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I am able to reproduce this on windows without the const std = @import("std");
pub const Foo = packed struct {
a: u31,
b: bool,
pub fn init() Foo {
return .{ .a = undefined, .b = true };
}
};
pub fn main() !void {
const a = Foo.init();
std.debug.print("{} {b}\n", .{a.b, @as(u32, @bitCast(a))});
// Expected "true", and a non zero value
// Found "false", 0
} $ zig run foo.zig
true 10111000111110011110110010010000
$ zig run foo.zig
false 10111010011011010010010110000 |
Duplicate of #20095 |
I believe this issue is only in the llvm backend: const exe = b.addExecutable(.{
.name = "foo2",
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
.use_llvm = false,
});
|
I'd expect it to be caused by the same issue but we can keep this open too. |
I'm observing something similar (the same?) with this minimal repro on
Note that this problem is fixed for me with |
incomplete
incomplete the zig team is perfectly capable of finding and fixing bugs ourselves. if you file an issue you're basically asking for priority service. if you want priority service then please fill out the damn form. |
I think your GitHub page may be having problems because the reproduction steps and expected behavior are in #20938 (comment). Aside from that, I reran the original reproduction and the issue seems to have been fixed at some point as Ryp mentioned. // foo.zig
const std = @import("std");
pub const Foo = packed struct {
a: u31,
b: bool,
pub fn init() Foo {
return .{ .a = undefined, .b = true };
}
};
pub fn main() !void {
const a = Foo.init();
std.debug.print("{} {b}\n", .{ a.b, @as(u32, @bitCast(a)) });
// Expected "true", and a non zero value
// Found "false", 0
}
|
although farfetched it is very charitable, thank you for that gesture. I see these comments upon closer examination: // Expected "true", and a non zero value
// Found "false", 0 so this was a case of triaging too fast. sometimes when something is a little bit sloppy (it didn't pedantically fill out the form) but technically ok, it can easily be misidentified as yet another crappy issue report in a sea of crappy issue reports. I apologize but I'm also going to reserve the right to close issues that don't pedantically fill out the template |
Also swap GPUSTAT and GPUREAD so that it doesn't return garbage Bumped zig version to 0.14-master, since there's a bug on 0.13.0 that's impacting me. See ziglang/zig#20938
Uh oh!
There was an error while loading. Please reload this page.
Zig Version
0.14.0-dev.839+a931bfada
Steps to Reproduce and Observed Behavior
Expected Behavior
There seems to be an issue with passing a packed struct into a function when the first field is initialized as undefined.
The text was updated successfully, but these errors were encountered: