https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105294
Matthew House <mattlloydhouse at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |mattlloydhouse at gmail dot com --- Comment #2 from Matthew House <mattlloydhouse at gmail dot com> --- Isn't this example invalid per the spec? At `*r = 42;`, `&*r` is based on `s`. However, `*p = 13;` modifies the same object that `*r` refers to, and `&*p` is not based on `s`, so the behavior is undefined. I've recently found another example which is valid under the current spec as well as the two new proposed definitions in N3025 and N3058. https://godbolt.org/z/ezvMfPd78 static int x; __attribute__ ((noinline)) int f(int * restrict p) { *p = 1; if (p == &x) { *p = 2; } return *p; } int main(void) { return f(&x); } At `*p = 2;`, `&*p` is based on `p` under every definition. However, both GCC and Clang incorrectly assume that the write to `*p` inside the `if` block cannot affect the return value.