https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90027
Eric Botcazou <ebotcazou at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED CC| |ebotcazou at gcc dot gnu.org Resolution|--- |INVALID --- Comment #1 from Eric Botcazou <ebotcazou at gcc dot gnu.org> --- > A test cases: > int foo () > { > volatile int *pswData = 2; /* point to address 2 is not aligned with 4 > bytes. */ > return *pswData - *pswData; > } That precisely makes it undefined behavior, see 6.5.3.2: "The unary * operator denotes indirection. If the operand points to a function, the result is a function designator; if it points to an object, the result is an lvalue designating the object. If the operand has type ‘‘pointer to type’’, the result has type ‘‘type’’. If an invalid value has been assigned to the pointer, the behavior of the unary * operator is undefined(102)." "(102) Among the invalid values for dereferencing a pointer by the unary * operator are a null pointer, an address inappropriately aligned for the type of object pointed to, and the address of an object after the end of its lifetime."