Aliasing through a union member is valid.

Take back my previous TODO.
This commit is contained in:
David Neto 2015-11-23 15:15:41 -05:00
parent 15afbf9372
commit c9e0845c7f
2 changed files with 3 additions and 3 deletions

View File

@ -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;

View File

@ -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;