[Bug tree-optimization/84470] test for address of member being null not eliminated
rguenth at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Feb 27 11:35:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84470
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2018-02-27
Ever confirmed|0 |1
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Hmm, is p->a valid to compute if p is NULL? Is it valid to compute p->b if p
is NULL for
struct A { char a[4]; char b[4]; };
?
Because you say "could" in
if (p->a == 0) // could only be true when p is null
__builtin_abort (); // can be eliminated
which implies it would invoke undefined behavior?
ISTR we still want to not break old offsetof implementations using &(T
*)0->member
style computation?
But yes, wrapping rules say that &p->m is never NULL if m is not a member
at offset zero. See tree_single_nonzero_warnv_p for ADDR_EXPR handling.
More information about the Gcc-bugs
mailing list