diff --git a/include/internal/catch_tostring.hpp b/include/internal/catch_tostring.hpp index b463e4f..c081e94 100644 --- a/include/internal/catch_tostring.hpp +++ b/include/internal/catch_tostring.hpp @@ -83,17 +83,16 @@ namespace Detail { // Does not consider endian-ness template std::string rawMemoryToString( T value ) { - union - { - T value; + union { + T typedValue; unsigned char bytes[sizeof(T)]; - } valueAsBuffer; + }; - valueAsBuffer.value = value; + typedValue = value; std::ostringstream oss; oss << "0x"; - for( unsigned char* cp = valueAsBuffer.bytes; cp < valueAsBuffer.bytes+sizeof(T); ++cp ) + for( unsigned char* cp = bytes; cp < bytes+sizeof(T); ++cp ) oss << std::hex << std::setw(2) << std::setfill('0') << (unsigned int)*cp; return oss.str(); }