Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
saagarjha
on May 22, 2020
|
parent
|
context
|
favorite
| on:
Goals and Priorities for C++
> Will this be well-defined behavior?
No, it’s illegal in C++. Use std::bit_cast.
corysama
on May 22, 2020
[–]
You 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
on May 22, 2020
|
parent
[–]
Because he was using future tense, not past tense.
saagarjha
on May 22, 2020
|
root
|
parent
[–]
I doubt this will be changed in the future, especially since there have been multiple ways to represent this operation in the language now.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search:
No, it’s illegal in C++. Use std::bit_cast.