http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58173
Bug ID: 58173 Summary: [C++11] Bad interaction between sizeof... and remainder (%) operators Product: gcc Version: 4.8.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: lucdanton at free dot fr $ g++-snapshot --version g++-snapshot (GCC) 4.9.0 20130806 (experimental) $ cat main.cpp template<typename... T> struct foo { static constexpr auto N = sizeof...(T); struct bar { static_assert( N == 5, "" ); static_assert( (-1) % 5 == -1, "" ); static_assert( (-1) % N != -1, "" ); }; }; int main() { foo<int, int, int, int, int>::bar(); } $ g++-snapshot -std=c++11 main.cpp ------------------- That is, the compiler does not reject the program even though the three assertions cannot all hold simultaneously. As far as I can tell factoring the sizeof...(T) expression into N isn't necessary for the bug, and the use of the remainder operator is. This seems to happen with 4.8.1 as well.