This was missing a use of NSDMI when considering list-initialization via aggregate initialization in overload resolution.

Tested x86_64-pc-linux-gnu, applying to trunk and 5.

commit c2a038bbd3c2a82cc6f6679e5a70705f48571e07
Author: Jason Merrill <ja...@redhat.com>
Date:   Wed Mar 2 17:24:27 2016 -0500

    	* call.c (build_aggr_conv): Use get_nsdmi.

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 8d5582a..3ad3bd5 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -897,6 +897,8 @@ build_aggr_conv (tree type, tree ctor, int flags, tsubst_flags_t complain)
 
       if (i < CONSTRUCTOR_NELTS (ctor))
 	val = CONSTRUCTOR_ELT (ctor, i)->value;
+      else if (DECL_INITIAL (field))
+	val = get_nsdmi (field, /*ctor*/false);
       else if (TREE_CODE (ftype) == REFERENCE_TYPE)
 	/* Value-initialization of reference is ill-formed.  */
 	return NULL;
diff --git a/gcc/testsuite/g++.dg/cpp1y/nsdmi-aggr4.C b/gcc/testsuite/g++.dg/cpp1y/nsdmi-aggr4.C
new file mode 100644
index 0000000..71830cd
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/nsdmi-aggr4.C
@@ -0,0 +1,13 @@
+// { dg-do compile { target c++14 } }
+
+struct A
+{
+  A(int);
+};
+
+struct B
+{
+  A a{42};
+};
+
+B f() { return {}; }

Reply via email to