commit 4a67f791e454f5d04c8eabd0358b32e971ee0146
Author: Jason Merrill <jason@redhat.com>
Date: Tue Jun 15 01:08:24 2010 -0400
* call.c (convert_like_real): Don't complain about
list-value-initialization from an explicit constructor.
@@ -4956,7 +4956,10 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
/* When converting from an init list we consider explicit
constructors, but actually trying to call one is an error. */
- if (DECL_NONCONVERTING_P (convfn) && DECL_CONSTRUCTOR_P (convfn))
+ if (DECL_NONCONVERTING_P (convfn) && DECL_CONSTRUCTOR_P (convfn)
+ /* Unless we're calling it for value-initialization from an
+ empty list, since that is handled separately in 8.5.4. */
+ && cand->num_convs > 0)
{
if (complain & tf_error)
error ("converting to %qT from initializer list would use "
new file mode 100644
@@ -0,0 +1,12 @@
+// { dg-options "-std=c++0x" }
+
+struct A
+{
+ explicit A(int = 42);
+};
+
+int main()
+{
+ A a1 = { };
+ A a2 = { 24 }; // { dg-error "explicit" }
+}