https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92963
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |rguenth at gcc dot gnu.org --- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> --- To GCC the "mixing" makes it conservative, not assessing any 'restrict' on r and thus not disambiguate. Then we're jump-threading the second branch and thus instead of *r = 2 we suddenly see *p = 2 and that's _not_ aliasing the load from *q because you said so. That is, you're trying to use 'r' as a mean to make p based on q (or the other way around). That's probably not intended. Of course GCC comes along and makes r which might be based on p with some reading using q instead which clearly isn't. So yes, all this lexical semantic reasoning easily breaks down with an optimizing compiler. (and all this pointer provenance nonsense) I'm not convinced this is a bug in GCC. That you do if (p == q) is a good hint at that you're doing something not intended.