I'm saying that if you call foo with a null pointer, you get into
undefined behaviour territory. And GCC is founded to make
optimization based on that. And you -- as a user -- generally don't
know how and when GCC can apply that assumption. And it is already
doing so in known cases; it may do more in the future. I don't want
to go and give a long list of the specific cases; there is no point in
it. The transformation is general and will be applied where the
opportunity arises. Just don't count on dereferencing a null pointer
to result you or not result in a segfault in general.