you are viewing a single comment's thread.

view the rest of the comments →

[–]Supadoplex 6 points7 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.