From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5751 invoked by alias); 11 Jun 2010 12:51:46 -0000 Received: (qmail 5674 invoked by uid 48); 11 Jun 2010 12:51:28 -0000 Date: Fri, 11 Jun 2010 12:51:00 -0000 Message-ID: <20100611125128.5673.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug c++/44500] [C++0x] Bogus narrowing conversion error In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "redi at gcc dot gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2010-06/txt/msg01292.txt.bz2 ------- Comment #6 from redi at gcc dot gnu dot org 2010-06-11 12:51 ------- (In reply to comment #5) > So is it provable that for a "T op T" to be stored in T no narrowing takes > place? Yes, if the values are constants. > If the answer for T == char is no and for T == int it is yes this is rather > fishy ;-) That's not what I said. Look: #include struct A { char x; }; template void f() { A a = { C+D }; } template void g() { A a = { I+J }; } int main() { f<1, 1>(); // OK g<1, 1>(); // OK f(); // Error } f<1,1>() is ok, because C and D are constants. The type doesn't matter, the result of C+D is known at compile time and fits in a char. g<1,1>() is ok, because I and J are constants. The type doesn't matter, the result of I+J is known at compile time and fits in a char. f() is not ok, because the result is known at compile time and doesn't fit in a char. See 8.5.4 [dcl.init.list]p6 in teh C++0x draft for the full rules -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44500