diff --git a/source/endian.cpp b/source/endian.cpp index 39ecbcc4..8c39f295 100644 --- a/source/endian.cpp +++ b/source/endian.cpp @@ -33,7 +33,9 @@ enum { I32_ENDIAN_BIG = 0x00010203ul, }; -// TODO(dneto): This relies on undefined behaviour. Fix that. +// This constant value allows the detection of the host machine's endianness. +// Accessing it through the "value" member is valid due to C++11 section 3.10 +// paragraph 10. static const union { unsigned char bytes[4]; uint32_t value; diff --git a/test/UnitSPIRV.h b/test/UnitSPIRV.h index 15459155..808ad5eb 100644 --- a/test/UnitSPIRV.h +++ b/test/UnitSPIRV.h @@ -61,8 +61,6 @@ enum { I32_ENDIAN_BIG = 0x00010203ul, }; -// TODO(dneto): Using a union this way relies on undefined behaviour. -// Replace this with uses of BitwiseCast from util/bitutils.h static const union { unsigned char bytes[4]; uint32_t value;