Modifying a variable through a pointer of an incompatible type (other than unsigned char
) can lead to unpredictable results. This is often caused by a violation of aliasing rules. C, Section 6.5, para. 7 [ISO/IEC 9899:2011], specifies those circumstances in which an object may or may not be aliased.
...
Accessing an object by means of any other lvalue expression (other than unsigned char
) results in undefined behavior . See undefined behavior 34 of Annex J.
...