http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58093
Bug ID: 58093 Summary: Semi-bogus warning about narrowing conversions and variadic templates Product: gcc Version: 4.8.1 Status: UNCONFIRMED Severity: minor Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: nmm1 at cam dot ac.uk This may be related to 45397 and 53661, but it's not clear. The diagnostic is both confusing and makes many uses of variadic templates extremely confusing to their users. 4.13 [conv.rank], 4.7 [conv.integral] and 5 [expr] make it pretty clear that this is not a narrowing conversion, which makes the diagnostic very confusing. I agree that it potentially changes value, but the wording could be better (e.g. 'loss of sign'). That's the trivial part of this report. The more serious (but still minor) one is that I don't think that this is a soluble problem for the variadic template writer. It is unreasonable to have to convert arguments explicitly, when it's automatic under almost all circumstances. The following program: #include <iostream> using namespace std; template<typename ... Pack> void weeble (Pack ... Dims) { size_t r[] = {Dims...}; for (int i = 0; i < sizeof...(Dims); ++i) std::cout << " " << r[i]; std::cout << std::endl; } int main() { weeble(7,13,42,69); } produces: junk.cpp: In instantiation of 'void weeble(Pack ...) [with Pack = {int, int, int, int}]': junk.cpp:13:22: required from here junk.cpp:6:26: warning: narrowing conversion of 'Dims#0' from 'int' to 'size_t {aka long unsigned int}' inside { } [-Wnarrowing] size_t r[] = {Dims...}; ^ junk.cpp:6:26: warning: narrowing conversion of 'Dims#1' from 'int' to 'size_t {aka long unsigned int}' inside { } [-Wnarrowing] junk.cpp:6:26: warning: narrowing conversion of 'Dims#2' from 'int' to 'size_t {aka long unsigned int}' inside { } [-Wnarrowing] junk.cpp:6:26: warning: narrowing conversion of 'Dims#3' from 'int' to 'size_t {aka long unsigned int}' inside { } [-Wnarrowing] g++ -v produces: Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/home/nmm/GCC/lib/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)