3 ms·
I'm not sure 100%, but your second example does not imply UB. UB is caused by the act of accessing an object via a pointer of the wrong type, but just casting a
by pif 3y ago
I'm not sure 100%, but your second example does not imply UB. UB is caused by the act of accessing an object via a pointer of the wrong type, but just casting a pointer as you do should not be a problem.
On the other side, this would incur UB:
int32_t my_int = *((int32_t*)&my_float);