... and of course the problem with all such ideas is that we easily end up warning twice in all the simple cases which check_narrowing can already handle. Something like the attached has more chances of passing the testsuite while not regressing in terms of duplicate warnings (which are hard to notice)

Paolo.
Index: call.c
===================================================================
--- call.c      (revision 212431)
+++ call.c      (working copy)
@@ -3586,7 +3586,8 @@ build_user_type_conversion_1 (tree totype, tree ex
 
   /* It's OK to bind a temporary for converting constructor arguments, but
      not in converting the return value of a conversion operator.  */
-  convflags = ((flags & LOOKUP_NO_TEMP_BIND) | LOOKUP_NO_CONVERSION);
+  convflags = ((flags & LOOKUP_NO_TEMP_BIND) | LOOKUP_NO_CONVERSION
+              | (flags & LOOKUP_NO_NARROWING));
   flags &= ~LOOKUP_NO_TEMP_BIND;
 
   if (ctors)
Index: decl.c
===================================================================
--- decl.c      (revision 212431)
+++ decl.c      (working copy)
@@ -5757,7 +5757,12 @@ check_initializer (tree decl, tree init, int flags
            {
              init = reshape_init (type, init, tf_warning_or_error);
              if (SCALAR_TYPE_P (type))
-               check_narrowing (type, init);
+               {
+                 if (!CLASS_TYPE_P (TREE_TYPE (init)))
+                   check_narrowing (type, init);
+                 else
+                   flags |= LOOKUP_NO_NARROWING;
+               }
            }
        }
       else if (TREE_CODE (init) == TREE_LIST

Reply via email to