taocpp / PEGTL

Parsing Expression Grammar Template Library
Boost Software License 1.0
1.94k stars 228 forks source link

Unit test failure on s390x architecture #120

Closed dkopecek closed 6 years ago

dkopecek commented 6 years ago

Hi, I've tried to run the PEGTL unit tests on a Linux s390x machine and got the following errors:

pegtl: unit test assert [ internal::h_to_le( std::int16_t( 0x7a39 ) ) == std::int16_t( 0x7a39 ) ] failed in line [ 53 ] file [ src/test/pegtl/internal_endian.cpp ]
pegtl: unit test assert [ internal::h_to_le( std::uint16_t( 0x7a39 ) ) == std::uint16_t( 0x7a39 ) ] failed in line [ 54 ] file [ src/test/pegtl/internal_endian.cpp ]
pegtl: unit test assert [ internal::h_to_be( std::int16_t( 0x7a39 ) ) == std::int16_t( 0x397a ) ] failed in line [ 55 ] file [ src/test/pegtl/internal_endian.cpp ]
pegtl: unit test assert [ internal::h_to_be( std::uint16_t( 0x7a39 ) ) == std::uint16_t( 0x397a ) ] failed in line [ 56 ] file [ src/test/pegtl/internal_endian.cpp ]
pegtl: unit test assert [ internal::le_to_h( std::int16_t( 0x7a39 ) ) == std::int16_t( 0x7a39 ) ] failed in line [ 57 ] file [ src/test/pegtl/internal_endian.cpp ]
pegtl: unit test assert [ internal::le_to_h( std::uint16_t( 0x7a39 ) ) == std::uint16_t( 0x7a39 ) ] failed in line [ 58 ] file [ src/test/pegtl/internal_endian.cpp ]
pegtl: unit test assert [ internal::be_to_h( std::int16_t( 0x7a39 ) ) == std::int16_t( 0x397a ) ] failed in line [ 59 ] file [ src/test/pegtl/internal_endian.cpp ]
pegtl: unit test assert [ internal::be_to_h( std::uint16_t( 0x7a39 ) ) == std::uint16_t( 0x397a ) ] failed in line [ 60 ] file [ src/test/pegtl/internal_endian.cpp ]
pegtl: unit test assert [ internal::h_to_le( std::int32_t( 0x7a391f2b ) ) == std::int32_t( 0x7a391f2b ) ] failed in line [ 62 ] file [ src/test/pegtl/internal_endian.cpp ]
pegtl: unit test assert [ internal::h_to_le( std::uint32_t( 0x7a391f2b ) ) == std::uint32_t( 0x7a391f2b ) ] failed in line [ 63 ] file [ src/test/pegtl/internal_endian.cpp ]
pegtl: unit test assert [ internal::h_to_be( std::int32_t( 0x7a391f2b ) ) == std::int32_t( 0x2b1f397a ) ] failed in line [ 64 ] file [ src/test/pegtl/internal_endian.cpp ]
pegtl: unit test assert [ internal::h_to_be( std::uint32_t( 0x7a391f2b ) ) == std::uint32_t( 0x2b1f397a ) ] failed in line [ 65 ] file [ src/test/pegtl/internal_endian.cpp ]
pegtl: unit test assert [ internal::le_to_h( std::int32_t( 0x7a391f2b ) ) == std::int32_t( 0x7a391f2b ) ] failed in line [ 66 ] file [ src/test/pegtl/internal_endian.cpp ]
pegtl: unit test assert [ internal::le_to_h( std::uint32_t( 0x7a391f2b ) ) == std::uint32_t( 0x7a391f2b ) ] failed in line [ 67 ] file [ src/test/pegtl/internal_endian.cpp ]
pegtl: unit test assert [ internal::be_to_h( std::int32_t( 0x7a391f2b ) ) == std::int32_t( 0x2b1f397a ) ] failed in line [ 68 ] file [ src/test/pegtl/internal_endian.cpp ]
pegtl: unit test assert [ internal::be_to_h( std::uint32_t( 0x7a391f2b ) ) == std::uint32_t( 0x2b1f397a ) ] failed in line [ 69 ] file [ src/test/pegtl/internal_endian.cpp ]
pegtl: unit test assert [ internal::h_to_le( std::int64_t( 0x7a391f2b33445567 ) ) == std::int64_t( 0x7a391f2b33445567 ) ] failed in line [ 71 ] file [ src/test/pegtl/internal_endian.cpp ]
pegtl: unit test assert [ internal::h_to_le( std::uint64_t( 0x7a391f2b33445567 ) ) == std::uint64_t( 0x7a391f2b33445567 ) ] failed in line [ 72 ] file [ src/test/pegtl/internal_endian.cpp ]
pegtl: unit test assert [ internal::h_to_be( std::int64_t( 0x7a391f2b33445567 ) ) == std::int64_t( 0x675544332b1f397a ) ] failed in line [ 73 ] file [ src/test/pegtl/internal_endian.cpp ]
pegtl: unit test assert [ internal::h_to_be( std::uint64_t( 0x7a391f2b33445567 ) ) == std::uint64_t( 0x675544332b1f397a ) ] failed in line [ 74 ] file [ src/test/pegtl/internal_endian.cpp ]
pegtl: unit test assert [ internal::le_to_h( std::int64_t( 0x7a391f2b33445567 ) ) == std::int64_t( 0x7a391f2b33445567 ) ] failed in line [ 75 ] file [ src/test/pegtl/internal_endian.cpp ]
pegtl: unit test assert [ internal::le_to_h( std::uint64_t( 0x7a391f2b33445567 ) ) == std::uint64_t( 0x7a391f2b33445567 ) ] failed in line [ 76 ] file [ src/test/pegtl/internal_endian.cpp ]
pegtl: unit test assert [ internal::be_to_h( std::int64_t( 0x7a391f2b33445567 ) ) == std::int64_t( 0x675544332b1f397a ) ] failed in line [ 77 ] file [ src/test/pegtl/internal_endian.cpp ]
pegtl: unit test assert [ internal::be_to_h( std::uint64_t( 0x7a391f2b33445567 ) ) == std::uint64_t( 0x675544332b1f397a ) ] failed in line [ 78 ] file [ src/test/pegtl/internal_endian.cpp ]

Linux on s390x is big-endian.

dkopecek commented 6 years ago

I've found a quick fix and submitted via PR#121. Probably can't be called "Art of C++" because of the C-style cast but it works for me and at least shows the right direction how to fix the issue ;-)

ColinH commented 6 years ago

Thank you, I'll look into the pull request later today.