------- Comment #8 from redi at gcc dot gnu dot org 2010-06-11 13:20 ------- (In reply to comment #7) > He is referring to a testcase like: > > template<typename T, T C> void f() { > struct A { > T x; > }; > > T y = 42; > A a = { y + C }; > } > > int main() { > f<int,1>(); > f<char,1>(); > } > > So, we warn for T == char but not for T == int. I know that the standard
Note it's not a warning, it's an error, mandated by the standard. > considers differently narrowing and overflow but the difference is still > surprising. In both cases, T+T has type int, so obviously it fits in an int. It doesn't necessarily fit in an char, so is an error unless the values are constants and the actual value can fit in a char. This is mandated by the standard and the diagnostic is IMHO clear. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44500