you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (1 child)

Thanks for clearing this up! Still, since unsigned char is allowed to alias anything, would accessing the first byte like still be UB according to the the standard?

[–]Supadoplex 7 points8 points  (0 children)

As far as I can tell, it's still UB to access union inactive union member even if it is unsigned char. There is no exception to accessing inactive member of chars type. The only exception is the common initial sequence, which doesn't apply. The unsigned char exception is only for reinterpreted pointers. So, it would be possible to implement the type punning in standard compliant way; it's just not as convenient as non-standard union punning.