[Bug c++/89214] [7/8/9 Regression] ICE in digest_init_r, at cp/typeck2.c:1211 with -std=c++17
mpolacek at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Mar 21 19:42:00 GMT 2019
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;
}
More information about the Gcc-bugs
mailing list