https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89214

--- Comment #9 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
And a fix:

--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -5978,6 +5978,18 @@ reshape_init_class (tree type, reshape_iter *d, bool
first_initializer_p,
       field = next_initializable_field (DECL_CHAIN (field));
     }

+  /* "If T is a class type and the initializer list has a single
+     element of type cv U, where U is T or a class derived from T,
+     the object is initialized from that element."  */
+  if (cxx_dialect >= cxx11
+      && BRACE_ENCLOSED_INITIALIZER_P (new_init)
+      && CONSTRUCTOR_NELTS (new_init) == 1)
+    {
+      tree elt = CONSTRUCTOR_ELT (new_init, 0)->value;
+      if (reference_related_p (type, TREE_TYPE (elt)))
+   return elt;
+    }
+
   return new_init;
 }

Reply via email to