[Bug c++/70196] inconsistent constness of inequality of weak symbol addresses
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70196 Eric Gallager changed: What|Removed |Added See Also||https://gcc.gnu.org/bugzill ||a/show_bug.cgi?id=81453 --- Comment #6 from Eric Gallager --- (In reply to Eric Gallager from comment #5) > (In reply to Nathan Sidwell from comment #4) > > 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 > > > > Right, there's a warning from -Wextra for that, there's a bug to split it > off into its own warning, too... ...right, bug 81453
[Bug c++/70196] inconsistent constness of inequality of weak symbol addresses
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70196 --- Comment #5 from Eric Gallager --- (In reply to Nathan Sidwell from comment #4) > 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 > Right, there's a warning from -Wextra for that, there's a bug to split it off into its own warning, too...
[Bug c++/70196] inconsistent constness of inequality of weak symbol addresses
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70196 --- Comment #4 from Nathan Sidwell --- 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.
[Bug c++/70196] inconsistent constness of inequality of weak symbol addresses
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70196 Eric Gallager changed: What|Removed |Added CC||jason at gcc dot gnu.org, ||nathan at gcc dot gnu.org --- Comment #3 from Eric Gallager --- cc-ing C++ FE maintainers
[Bug c++/70196] inconsistent constness of inequality of weak symbol addresses
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70196 Eric Gallager changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2017-08-28 CC||egallager at gcc dot gnu.org Ever confirmed|0 |1 Known to fail||8.0 --- Comment #2 from Eric Gallager --- Combined into a single testcase and confirmed: $ cat 70196.cc && /usr/local/bin/g++ -c -S -Wall -Wextra -Wpedantic -xc++ 70196.cc extern __attribute__ ((weak)) int i; constexpr int *p = 0; constexpr int *q = &i; static_assert (p == q, "p == q"); static_assert (!(q < p), "!(a < p)"); // accepted and true static_assert (p <= q, "p <= q"); // accepted and true template struct S { }; S s0; // accepted S<&i == 0> s1; // rejected 70196.cc:6:1: error: non-constant condition for static assertion static_assert (p == q, "p == q"); ^ 70196.cc:6:18: error: ‘((& i) == 0)’ is not a constant expression static_assert (p == q, "p == q"); ~~^~~~ 70196.cc:12:10: warning: ordered comparison of pointer with integer zero [-Wextra] S s0; // accepted ^ 70196.cc:13:10: error: template argument 1 is invalid S<&i == 0> s1; // rejected ^ $
[Bug c++/70196] inconsistent constness of inequality of weak symbol addresses
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70196 Martin Sebor changed: What|Removed |Added Keywords||accepts-invalid Known to fail||4.9.3, 5.3.0, 6.0 --- Comment #1 from Martin Sebor --- All supported versions behave this way. This is also not specific to constexpr but a more general issue. Below is a test case that doesn't involve constexpr. $ cat v.c && /home/msebor/build/gcc-trunk-svn/gcc/xgcc -B/home/msebor/build/gcc-trunk-svn/gcc -S -Wall -Wextra -Wpedantic -o/dev/null -std=c++11 -xc++ v.c extern __attribute__ ((weak)) int i; template struct S { }; S s0; // accepted S<&i == 0> s1; // rejected v.c:5:10: warning: ordered comparison of pointer with integer zero [-Wextra] S s0; // accepted ^ v.c:6:10: error: template argument 1 is invalid S<&i == 0> s1; // rejected ^