2 ms·
Nope, it's undefined: > Accessing an object by means of any other lvalue expression (other than unsigned char) is undefined behavior https://wiki.sei.cmu.edu/
by saagarjha 9y ago
Nope, it's undefined:
> Accessing an object by means of any other lvalue expression (other than unsigned char) is undefined behavior
https://wiki.sei.cmu.edu/confluence/display/c/EXP39-C.+Do+not+access+a+variable+through+a+pointer+of+an+incompatible+type https://wiki.sei.cmu.edu/confluence/display/c/EXP39-C.+Do+no...
- ithkuil 9y agoI don't understand your comment. The link you pasted explicitly mentions the union example as a "compliant solution". That said, memcpy and a compiler that understand the memcpy intrinsic is probably safer; that said I have a vague memory of hitting an embedded compiler where memcpy wasn't an intrinsic