commit 25767f0e366840ff8d1c334830785c2cba9c09cc
Author: Jason Merrill <jason@redhat.com>
Date: Wed Jun 15 15:20:18 2011 -0400
PR c++/45378
* decl.c (check_initializer): Check narrowing.
@@ -5464,7 +5464,11 @@ check_initializer (tree decl, tree init, int flags, tree *cleanup)
init = error_mark_node;
}
else
- init = reshape_init (type, init, tf_warning_or_error);
+ {
+ init = reshape_init (type, init, tf_warning_or_error);
+ if (cxx_dialect >= cxx0x && SCALAR_TYPE_P (type))
+ check_narrowing (type, init);
+ }
}
/* If DECL has an array type without a specific bound, deduce the
new file mode 100644
@@ -0,0 +1,7 @@
+// PR c++/45378
+// { dg-options -std=c++0x }
+
+int main()
+{
+ int x { 22.2 }; // { dg-error "narrowing" }
+}