On Tue, Mar 6, 2018 at 12:42 AM, Alexandre Oliva <aol...@redhat.com> wrote: > On Mar 2, 2018, Jason Merrill <ja...@redhat.com> wrote: > >> On Fri, Mar 2, 2018 at 2:57 AM, Alexandre Oliva <aol...@redhat.com> wrote: >>> + gcc_assert (TREE_CODE (type) == REFERENCE_TYPE); >>> + init = fold (convert (type, integer_zero_node)); > >> Maybe build_zero_cst? > > Sure. > > > I wonder, is there any reason to not change any of these to use > build_zero_cst, too? > > else if (TYPE_PTR_OR_PTRMEM_P (type)) > init = fold (convert (type, nullptr_node)); > else if (SCALAR_TYPE_P (type)) > init = fold (convert (type, integer_zero_node)); > > I suppose pointers to members might need an explicit conversion, which > build_zero_cst might fallback to if it doesn't consider them aggregate > types. As for scalar types, are there any C++-specific scalar types > that build_zero_cst wouldn't know how to deal with? Anyway, it's > probably not the time to change these, if it doesn't fix a regression. > Just curious.
Indeed, build_zero_cst is wrong for pointers to members, but it should be right for other scalars, including regular pointers. Jason