[C++ Patch/RFC] Back to PR 53159

Paolo Carlini paolo.carlini@oracle.com
Thu Jul 10 22:32:00 GMT 2014


... the below is another, very safe, option for setting 
LOOKUP_NO_NARROWING in flags.

Paolo.
-------------- next part --------------
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)
@@ -5755,6 +5755,7 @@ check_initializer (tree decl, tree init, int flags
 	    }
 	  else
 	    {
+	      flags |= LOOKUP_NO_NARROWING;
 	      init = reshape_init (type, init, tf_warning_or_error);
 	      if (SCALAR_TYPE_P (type))
 		check_narrowing (type, init);


More information about the Gcc-patches mailing list