[Bug c++/70196] inconsistent constness of inequality of weak symbol addresses

nathan at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue May 28 11:27:00 GMT 2019


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

--- Comment #4 from Nathan Sidwell <nathan at gcc dot gnu.org> ---
ordering comparison of pointers is only well-defined when the two pointers
point into the same object (including one-past-the-end). [expr.ref]/4

No object can have a NULL address.

The third bullet permits a compiler to /always/ return true (or false) for any
stricly ordered relational pointer comparison involving a null pointer
constant. (AFAICT even '(void *)0 < 0' is included in that).  The -or-equal
operators coult be expanded to '(strict-order) | (equality-cmp)', and then
simplified based on what constant we chose the strict-order to always return.

Now, that said, I think the problematic statement in the example is:
  constexpr int *q = &i;

That should probably be rejected, as it assigns the set {NULL, obj-addr} to q.


More information about the Gcc-bugs mailing list