With 4.8.1: template<int ... Dims> class weeble { static constexpr int Ranks[sizeof...(Dims)] = {Dims...}; const int rank = sizeof...(Dims); }; weeble<3,5> x; produces: junk.cpp:4:22: error: expected ';' at end of member declaration const int rank = sizeof...(Dims); ^ junk.cpp:4:28: error: expected unqualified-id before '...' token const int rank = sizeof...(Dims); ^ junk.cpp:4:22: error: expected primary-expression at end of input const int rank = sizeof...(Dims); ^ That doesn't look right, especially as that use of sizeof... is almost straight out of the standard. For what it is worth, -v produces: Using built-in specs. COLLECT_GCC=/home/nmm/GCC/bin/g++ COLLECT_LTO_WRAPPER=/home/nmm/GCC/libexec/gcc/x86_64-unknown-linux-gnu/4.8.1/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../configure --prefix=/home/nmm/GCC --disable-bootstrap --enable-languages=c,c++,fortran --enable-werror=yes --disable-decimal-float Thread model: posix gcc version 4.8.1 (GCC)
The compiler only rejects it when the member is non-static and uses = for the initializer. As a workaround you can use a braced-init-list as the initializer for the member: const int rank { sizeof...(Dims) };
Thanks. That's simpler than my workaround.
Dup. Already fixed in mainline. *** This bug has been marked as a duplicate of bug 57673 ***