1. Breaking reflexivity is not OK. Ever. a==a should hold.
2. The compiler knows that this is undefined behavior, and uses this to "optimize" to a wrong result.
However, it does not warn me about the use of undefined behavior. Not with -Wall, not with -Wpedantic.
marcel@localhost[tmp]cc -Wall -Wpedantic -Os -o undefined-realloc undefined-realloc.c
marcel@localhost[tmp]./undefined-realloc
1 2
I can't think of any reason for this to be OK. Either warn me, or don't use it. Silently breaking reflexivity...did I mention "not OK"?Of course, that's only a minor point in the article, but it does capture the theme that's explored in the main point.