zig icon indicating copy to clipboard operation
zig copied to clipboard

Native backend behavior with packed struct equality not matching llvm

Open actondev opened this issue 9 months ago • 2 comments

Zig Version

0.14.0-dev.3298+6fe1993d8

Steps to Reproduce and Observed Behavior

zig test shortcuts2.zig -fno-llvm fails while zig test shortcuts2.zig passes. See in the code the 2 relevant // TODO.. comments.

Long story short, comparing 2 packed structs with std.meta.eql fails with -fno-llvm, while doing a manual

const backing = @typeInfo(Self).@"struct".backing_integer.?;
return @as(backing, @bitCast(self)) == @as(backing, @bitCast(other));

passes.

Also, in a TODO comments, I noticed that when removing a field from another struct, not of compared one, the -fno-llvm passes !?

Pardon the long reproduction scenario, but when I tried to do something slimmed down I couldn't reproduce the behacior.

PS: apparently github doesn't allow attaching .zig files..

shortcuts2.txt

Expected Behavior

Should have same behavior

actondev avatar Feb 23 '25 11:02 actondev

still present in 0.14.1

actondev avatar May 27 '25 17:05 actondev

Oh, actually a simple packed struct equality bug (frontend support was added without verification that backend support was functional.

jacobly0 avatar Jun 01 '25 03:06 jacobly0