2 ms·
> Will this be well-defined behavior? No, it’s illegal in C++. Use std::bit_cast.
by saagarjha 7y ago
> Will this be well-defined behavior?
No, it’s illegal in C++. Use std::bit_cast.
- corysama 7y agoYou apparently are being downvoted unfairly while you are correct. Writing to u64 then reading from u32 is undefined behavior in C++. Only reading from the last union member that was written to is defined.
- danielscrubs 7y agoBecause he was using future tense, not past tense.
- saagarjha 7y agoI doubt this will be changed in the future, especially since there have been multiple ways to represent this operation in the language now.