Skip to content
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

behavior.union.test.reinterpret packed union fails on big endian targets #21050

Open
alexrp opened this issue Aug 12, 2024 · 2 comments
Open
Labels
arch-mips 32-bit and 64-bit MIPS arch-powerpc 32-bit and 64-bit Power ISA arch-s390x 64-bit IBM z/Architecture backend-llvm The LLVM backend outputs an LLVM IR Module. bug Observed behavior contradicts documented or intended behavior
Milestone

Comments

@alexrp
Copy link
Member

alexrp commented Aug 12, 2024

Zig Version

9ef16b3

Steps to Reproduce and Observed Behavior

Run e.g. zig test -target mips-linux-none test/behavior/union.zig --test-cmd qemu-mips --test-cmd-bin.

error: 'behavior.union.test.reinterpret packed union' failed: expected 42, found 187
/home/alexrp/Source/zig/lib/std/testing.zig:97:17: 0x2dc983 in expectEqualInner__anon_30353 (test)
                return error.TestExpectedEqual;
                ^
/home/alexrp/Source/zig/test/behavior/union.zig:1860:17: 0x42b067 in doTheTest (test)
                try expectEqual(@as(u8, 0x2a), u.foo);
                ^
/home/alexrp/Source/zig/test/behavior/union.zig:1908:5: 0x42b903 in test.reinterpret packed union (test)
    try S.doTheTest();
    ^

Notably, the test does not fail for mipsel-linux-*.

Expected Behavior

No failure.

@alexrp alexrp added the bug Observed behavior contradicts documented or intended behavior label Aug 12, 2024
alexrp added a commit to alexrp/zig that referenced this issue Aug 12, 2024
alexrp added a commit to alexrp/zig that referenced this issue Aug 12, 2024
@Vexu Vexu added arch-mips 32-bit and 64-bit MIPS backend-llvm The LLVM backend outputs an LLVM IR Module. labels Aug 12, 2024
@Vexu Vexu added this to the 0.16.0 milestone Aug 12, 2024
SammyJames pushed a commit to SammyJames/zig that referenced this issue Aug 15, 2024
@alexrp
Copy link
Member Author

alexrp commented Sep 4, 2024

This also fails on big endian PowerPC, but not little endian, just like MIPS. I'm convinced it's an endianness bug at this point.

@alexrp alexrp changed the title behavior.union.test.reinterpret packed union fails on mips-linux-* behavior.union.test.reinterpret packed union fails on mips-linux-*, powerpc-linux-*, powerpc64-linux-* Sep 4, 2024
@nektro
Copy link
Contributor

nektro commented Sep 8, 2024

this also fails on s390x which is also a big endian architecture

@alexrp alexrp changed the title behavior.union.test.reinterpret packed union fails on mips-linux-*, powerpc-linux-*, powerpc64-linux-* behavior.union.test.reinterpret packed union fails on big endian targets Sep 17, 2024
@alexrp alexrp added arch-powerpc 32-bit and 64-bit Power ISA arch-s390x 64-bit IBM z/Architecture labels Oct 3, 2024
richerfu pushed a commit to richerfu/zig that referenced this issue Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-mips 32-bit and 64-bit MIPS arch-powerpc 32-bit and 64-bit Power ISA arch-s390x 64-bit IBM z/Architecture backend-llvm The LLVM backend outputs an LLVM IR Module. bug Observed behavior contradicts documented or intended behavior
Projects
None yet
Development

No branches or pull requests

3 participants