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

5m read timeFrom sandordargo.com
Post cover image
Table of contents
The suspectThe fine print almost nobody knows aboutWhy character types matterConclusionConnect deeper

Sort: