Accessing inactive union members through char: the aliasing rule you didn't know about
This title could be clearer and more informative.Try out Clickbait Shieldfor free (5 uses left this month).
A deep dive into a subtle C++ aliasing rule that permits accessing an inactive union member through a char type without triggering undefined behavior. The post examines an OptBool struct from the std::is_within_lifetime proposal, where union storage is read via a char member even when bool is the active member. The C++ standard
Table of contents
The suspectThe fine print almost nobody knows aboutWhy character types matterConclusionConnect deeperSort: