On Fri, Mar 2, 2018 at 2:57 AM, Alexandre Oliva <aol...@redhat.com> wrote: > On Feb 28, 2018, Jason Merrill <ja...@redhat.com> wrote: > >> On Wed, Feb 28, 2018 at 7:08 AM, Alexandre Oliva <aol...@redhat.com> wrote: >>> Don't allow the initializer expr to be NULL in a ctor initializer >>> list, make it error_marker_node instead. > >> I don't want error_mark_nodes in a CONSTRUCTOR, either. When there >> isn't an NSDMI to worry about, we zero-initialize the reference, and >> it seems reasonable to continue doing that, by fixing >> build_zero_init_1 to return something non-null for a reference. > > Like this? Regstrapped on i686- and x86_64-linux-gnu. > > [PR c++/84593] ice on braced init with uninit ref field > > If an initializer expr is to be NULL in a ctor initializer list, we > ICE in picflag_from_initializer and elsewhere. > > If we're missing an initializer for a reference field, we report the > error, but then build a zero initializer to avoid the ICE. > > for gcc/cp/ChangeLog > > PR c++/84593 > * init.c (build_zero_init_1): Zero-initialize references. > > for gcc/testsuite/ChangeLog > > PR c++/84593 > * g++.dg/cpp1y/pr84593.C: New. > --- > gcc/cp/init.c | 5 ++++- > gcc/testsuite/g++.dg/cpp1y/pr84593.C | 8 ++++++++ > 2 files changed, 12 insertions(+), 1 deletion(-) > create mode 100644 gcc/testsuite/g++.dg/cpp1y/pr84593.C > > diff --git a/gcc/cp/init.c b/gcc/cp/init.c > index d0d14abdc9fa..ed28e9a46dbc 100644 > --- a/gcc/cp/init.c > +++ b/gcc/cp/init.c > @@ -284,7 +284,10 @@ build_zero_init_1 (tree type, tree nelts, bool > static_storage_p, > else if (VECTOR_TYPE_P (type)) > init = build_zero_cst (type); > else > - gcc_assert (TREE_CODE (type) == REFERENCE_TYPE); > + { > + gcc_assert (TREE_CODE (type) == REFERENCE_TYPE); > + init = fold (convert (type, integer_zero_node));
Maybe build_zero_cst? OK either way. Jason