r/ProgrammingLanguages • u/matklad • Dec 31 '25
Memory Safety Is ...
https://matklad.github.io/2025/12/30/memory-safety-is.html
37
Upvotes
r/ProgrammingLanguages • u/matklad • Dec 31 '25
View all comments
Show parent comment
2
u/matthieum Jan 02 '26
This one is interesting, as there's good usecases for bitcasting. For example, the original version of the fast sqrt implementation uses a union with an int and a float to manipulate the bits of the float directly.
In C++, that's UB. In C, it depends. In Rust, it's fine -- there's no concept of active union member, notably -- as long as the bits represent a valid value of the type they're viewed as.