Tag: type-punning
-
Does nullptr_t break type punning or pointer conversions?
7 Consider this union: typedef union { void* vptr; nullptr_t nptr; } pun_intended; nullptr_t is supposedly compatible with void*. Ok so what if we initialize the void* to some non-zero value? pun_intended foo = { .vptr = (void*)42 }; This conversion is supposedly legit (impl.defined) as per C23 6.3.2.3 §4, or at least it was…