With GCC 6.4 or 7.2, the following example fails to compile in C++14 mode: === start === template<typename T> struct C { static constexpr int x = 5; void f() { static_assert(0 < x, "x"); // ok static_assert(0 < (x), "x"); // fails static_assert(true || (0 < x), "x"); // ok static_assert(true || (0 < (x)), "x"); // fails } }; === end === $ g++ -c -std=c++14 foo.cc foo.cc: In member function ‘void C<T>::f()’: foo.cc:7:7: error: non-constant condition for static assertion static_assert(0 < (x), "x"); // fails ^~~~~~~~~~~~~ foo.cc:9:7: error: non-constant condition for static assertion static_assert(true || (0 < (x)), "x"); // fails ^~~~~~~~~~~~~ OTOH, -std=c++11 works fine. GCC 5.4 with -std=c++14 also compiles. Also, removing "template<typename T>" or moving the definition of "x" out of the template makes it compile. Tested on x86_64-linux (NixOS). Compiler info: $ g++ -v Using built-in specs. COLLECT_GCC=/nix/store/l9nq5bvqgjngqhlq7ks6cg0bdizn2l0v-gcc-7.2.0/bin/g++ COLLECT_LTO_WRAPPER=/nix/store/l9nq5bvqgjngqhlq7ks6cg0bdizn2l0v-gcc-7.2.0/libexec/gcc/x86_64-unknown-linux-gnu/7.2.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: Thread model: posix gcc version 7.2.0 (GCC)
Fixed by r256550 but the test is useful.
The master branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>: https://gcc.gnu.org/g:953277ba3fa39a9285cf89f59932b0169e7f6b9d commit r11-4126-g953277ba3fa39a9285cf89f59932b0169e7f6b9d Author: Marek Polacek <polacek@redhat.com> Date: Tue Oct 20 10:15:41 2020 -0400 c++: Add fixed test [PR82239] This test was fixed by r256550 but that commit was fixing another issue, and just happened to fix this too. gcc/testsuite/ChangeLog: PR c++/82239 * g++.dg/cpp0x/static_assert16.C: New test.
Fixed.