https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84788
Bug ID: 84788 Summary: Parenthesis changes a constant to non-constant Product: gcc Version: 8.0.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: tuliom at linux dot vnet.ibm.com Target Milestone: --- Reproduced with GCC 8.0.1 rev. 258059: $ cat test-cxx.cpp template <int kKeybits> class PackedCache { public: static const int kValuebits = 7; static const int kValueMask = 1 << ((kValuebits)-1); }; $ g++ -c test-cxx.cpp test-cxx.cpp:5:53: error: non-constant in-class initialization invalid for static member ‘PackedCache<kKeybits>::kValueMask’ static const int kValueMask = 1 << ((kValuebits)-1); ^ test-cxx.cpp:5:53: note: (an out of class initialization is required) If the parenthesis around kValuebits is removed, the error disappears, i.e.: static const int kValueMask = 1 << (kValuebits-1); I can't reproduce this error with GCC 7. This file used to build with rev. 253122. I can build the file when using -std=gnu++11.