[Bug c++/53181] static_assert sees as non constant the comparison between a constexpr and a template argument
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53181 --- Comment #7 from Jonathan Wakely --- GCC 7 accepts it in C++17 mode because of r241137 Implement P0386R2 - C++17 inline variables That's because an out-of-class definition is not needed in C++17, the compiler will generate one from the in-class declaration.
[Bug c++/53181] static_assert sees as non constant the comparison between a constexpr and a template argument
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53181 Andrew Pinski changed: What|Removed |Added Last reconfirmed|2019-02-11 00:00:00 |2021-8-4 --- Comment #6 from Andrew Pinski --- So this is dependent on which standard you use. For C++11 and C++14, trunk is still rejecting it. For C++17, starting in GCC 7, the code is accepted and is correct. C++20 on trunk accepts it. It would be interesting to see why GCC 7+ acts this way. (In reply to Martin Sebor from comment #5) > No change in GCC 9. Actually there was :).
[Bug c++/53181] static_assert sees as non constant the comparison between a constexpr and a template argument
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53181 Martin Sebor changed: What|Removed |Added Known to fail|6.0 |6.3.0, 7.3.0, 8.2.0, 9.0 --- Comment #5 from Martin Sebor --- No change in GCC 9.
[Bug c++/53181] static_assert sees as non constant the comparison between a constexpr and a template argument
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53181 Martin Sebor changed: What|Removed |Added CC||msebor at gcc dot gnu.org Known to fail||4.9.3, 5.3.0, 6.0 --- Comment #4 from Martin Sebor --- Confirmed with all supported versions of GCC including the current trunk of 6.0. A slightly simplified test case: $ cat v.c && /home/msebor/build/gcc-trunk-git/gcc/xgcc -B/home/msebor/build/gcc-trunk-git/gcc -S -Wall -Wextra -Wpedantic -o/dev/null -xc++ v.c struct S { static constexpr char a[] = "A"; static constexpr char b[] = "A"; template static bool f () { constexpr bool isa = S == a; constexpr bool isb = S == b; return isa || isb; } }; template bool S::f(); template bool S::f(); v.c: In instantiation of ‘static bool S::f() [with const char* S = ((const char*)(& S::a))]’: v.c:13:26: required from here v.c:8:32: error: ‘(((const char*)(& S::a)) == ((const char*)(& S::b)))’ is not a constant expression constexpr bool isb = S == b; ~~^~~~ v.c: In instantiation of ‘static bool S::f() [with const char* S = ((const char*)(& S::b))]’: v.c:14:26: required from here v.c:7:32: error: ‘(((const char*)(& S::b)) == ((const char*)(& S::a)))’ is not a constant expression constexpr bool isa = S == a; ~~^~~~
[Bug c++/53181] static_assert sees as non constant the comparison between a constexpr and a template argument
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53181 Jason Merrill jason at gcc dot gnu.org changed: What|Removed |Added CC||jason at gcc dot gnu.org --- Comment #3 from Jason Merrill jason at gcc dot gnu.org --- The difference between the namespace- and class-scope cases is that the global declarations are known to be defined, while the static members don't have a visible out-of-class definition, and the middle end thinks it can't assume that two symbols defined elsewhere won't turn out to have the same address. Adding definitions of the static members causes the two cases to get the same result. constexpr char Test::wrong_string[]; constexpr char Test::right_string[]; We should probably override the middle end in this case.
[Bug c++/53181] static_assert sees as non constant the comparison between a constexpr and a template argument
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53181 --- Comment #2 from Paolo Carlini paolo.carlini at oracle dot com 2012-10-18 14:45:00 UTC --- In the case of wrong_string, fold_comparison (called from cp_build_binary_op via fold_if_not_in_template) cannot fold the comparison to a constant: base0 != base1. Most likely the issue is that we shouldn't end up passing such pointers.
[Bug c++/53181] static_assert sees as non constant the comparison between a constexpr and a template argument
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53181 Paolo Carlini paolo.carlini at oracle dot com changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2012-05-12 Ever Confirmed|0 |1 --- Comment #1 from Paolo Carlini paolo.carlini at oracle dot com 2012-05-12 22:16:36 UTC --- Confirmed.