Hi,

today I was having a look to c++/50855: for the testcase therein currently we are trying to just emit a "sorry, unimplemented: mangling constructor" and bail out. This is actually the case in 4_6-branch. In mainline, instead:

50855.C: In substitution of ‘template<class T> decltype ({256}) test(const T&) [with T = char]’:
50855.C:8:14: required from here
50855.C:2:6: warning: narrowing conversion of ‘256’ from ‘int’ to ‘char’ inside { } [-Wnarrowing]
50855.C: In function ‘int main()’:
50855.C:2:6: warning: narrowing conversion of ‘256’ from ‘int’ to ‘char’ inside { } [-Wnarrowing]
‘
Internal compiler error: Error reporting routines re-entered.

Now, I don't know if we can get to fixing the substantive issue in time for 4.7.0, but the patchlet below leads to (ie, similarly to 4_6-branch + Wnarrowing):

50855.C: In instantiation of ‘decltype ({256}) test(const T&) [with T = char; decltype ({256}) = char]’:
50855.C:8:14: required from here
50855.C:2:6: warning: narrowing conversion of ‘256’ from ‘int’ to ‘char’ inside { } [-Wnarrowing]
50855.C:2:6: sorry, unimplemented: mangling constructor

Tested x86_64-linux.

Thanks,
Paolo.

/////////////////////////////
2011-12-18  Paolo Carlini  <paolo.carl...@oracle.com>

        * semantics.c (finish_compound_literal): Don't call check_narrowing
        if !(complain & tf_warning).
Index: semantics.c
===================================================================
--- semantics.c (revision 182459)
+++ semantics.c (working copy)
@@ -2370,7 +2370,8 @@ finish_compound_literal (tree type, tree compound_
     return error_mark_node;
   compound_literal = reshape_init (type, compound_literal, complain);
   if (SCALAR_TYPE_P (type)
-      && !BRACE_ENCLOSED_INITIALIZER_P (compound_literal))
+      && !BRACE_ENCLOSED_INITIALIZER_P (compound_literal)
+      && (complain & tf_warning))
     check_narrowing (type, compound_literal);
   if (TREE_CODE (type) == ARRAY_TYPE
       && TYPE_DOMAIN (type) == NULL_TREE)

Reply via email to