------- Comment #2 from gpiez at web dot de 2010-06-11 11:34 ------- Sorry for the unicode mess. The error message is 'error: narrowing conversion of "(((int)y) + 1)" from "int" to "char" inside { }'.
The same error happens with a non templated function, but if I use two template parameters, the error disappears, even if they are to large. So this is at least very inconsistent. no error: struct A { <-->char x; }; template<char C, char D>void f() { <-->A a = { C+D }; } int main() { <-->f<1,2>(); } still no error: struct A { <-->char x; }; template<int C, int D>void f() { <-->A a = { C+D }; } int main() { <-->f<1,2>(); } error: struct A { <-->char x; }; void f(char C, char D) { <-->A a = { C+D }; } int main() { <-->f(1,2); } I believe I should not get an error, even if the template parameter type is larger than a char, as long as the template parameter value fits in in char, so template<int C> void f() { char y = 42; A a = { y+C }; } should give no error, as long as C fits in a char. IMHO ;-) -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44500