https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109945

--- Comment #31 from Arthur O'Dwyer <arthur.j.odwyer at gmail dot com> ---
Oops, I guess my reading did disagree with jwakely's in one small point:
jwakely writes--
> But since one of the pointers is an invalid pointer,
> you can't do anything with its value anyway, including
> comparing it to &w.

In my interpretation, it was fine to compare `global == &w`; but the boolean
value of that comparison would be unspecified (because `*global` was
out-of-lifetime), and even if it *did* happen to come out to `true`, it would
still be UB to execute `global->i = 42` (because `*global` would still be a
different object from `w`, and `*global` is out-of-lifetime). I think this
makes no difference to the ultimate conclusion, i.e. something here ends up
being UB either way.

Reply via email to