Skip to content

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

Closed

Description

@alexrp

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.

Activity

  1. added
    bug
    on Aug 12, 2024
  2. added
    arch-mips64
    backend-llvm
    on Aug 12, 2024
  3. added this to the 0.16.0 milestone on Aug 12, 2024
  4. alexrp commented on Sep 4, 2024

    @alexrp
    MemberAuthor

    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.

  5. 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-*`[/+] on Sep 4, 2024
  6. nektro commented on Sep 8, 2024

    @nektro
    Contributor

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

  7. 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[/+] on Sep 17, 2024
  8. added
    arch-powerpc64
    arch-s390x
    on Oct 3, 2024
  9. modified the milestones: upcoming, urgent on Jul 1, 2025
  10. added
    arch-mips
    arch-powerpc
    and removed
    arch-mips64
    arch-powerpc64
    arch-s390x
    arch-mips
    arch-powerpc
    on Oct 29, 2025
  11. modified the milestones: urgent, 0.17.0 on Apr 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    backend-llvmbug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions