You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
test"zero sized" {
constStruct=struct {
a: []constenum { a } = &.{}, // <-- note that this enum is 0 sized
};
constheader=trystd.json.parseFromSlice(
Struct,
std.testing.allocator,
"{\"a\": [\"a\"] }",
.{},
);
deferheader.deinit();
}
Results in this output:
test
└─ runtest
└─ zigtestDebugnative1errors/home/mason/Documents/zig/lib/std/mem.zig:4219:70: error: divisionbyzeroherecausesundefinedbehaviorreturn@as(cast_target, @ptrCast(bytes))[0..@divExact(bytes.len, @sizeOf(T))];
If you replace the zero sized enum with a non zero sized type, then it works as expected.
I caught this while upgrading a project to 0.14.0, so presumably the bug was introduced some time in the past few months, but I haven't checked exactly which version I was running previously.
Expected Behavior
I expected the test to pass.
The text was updated successfully, but these errors were encountered:
This actually seems to be an issue with bytesAsSlice, which is now called by remap (previously, resize did not call the function), as it doesn't check for the element size.
Zig Version
0.14.0
Steps to Reproduce and Observed Behavior
This test:
Results in this output:
If you replace the zero sized enum with a non zero sized type, then it works as expected.
I caught this while upgrading a project to 0.14.0, so presumably the bug was introduced some time in the past few months, but I haven't checked exactly which version I was running previously.
Expected Behavior
I expected the test to pass.
The text was updated successfully, but these errors were encountered: