This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH][PR c++/82888] smarter code for default initialization of scalar arrays
- From: Jason Merrill <jason at redhat dot com>
- To: Nathan Froyd <nfroyd at mozilla dot com>
- Cc: gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 21 Dec 2017 13:51:43 -0500
- Subject: Re: [PATCH][PR c++/82888] smarter code for default initialization of scalar arrays
- Authentication-results: sourceware.org; auth=none
- References: <5a0dbb28.4b279d0a.4c617.abaeSMTPIN_ADDED_MISSING@mx.google.com> <CADzB+2=mn0K==MzHC4c5x_v2Qgg9R851tQ5UD5D9OFVwJ4cwgA@mail.gmail.com> <CAGepuV+-K6Su3pos5GW1g9fEmJjbZbR7LsCgNB+x9p8D-N=K4Q@mail.gmail.com> <CADzB+2nUwJUhbCi3EU8bYr8RMdSq--bfNfA-maRoW_4cyV+E6w@mail.gmail.com>
On Wed, Nov 29, 2017 at 4:30 PM, Jason Merrill <jason@redhat.com> wrote:
> On Fri, Nov 17, 2017 at 11:04 PM, Nathan Froyd <nfroyd@mozilla.com> wrote:
>> On Fri, Nov 17, 2017 at 8:50 AM, Jason Merrill <jason@redhat.com> wrote:
>>> On Thu, Nov 16, 2017 at 11:21 AM, Nathan Froyd <froydnj@mozilla.com> wrote:
>>>> diff --git a/gcc/cp/init.c b/gcc/cp/init.c
>>>> index c76460d..53d6133 100644
>>>> --- a/gcc/cp/init.c
>>>> +++ b/gcc/cp/init.c
>>>> @@ -4038,6 +4038,15 @@ build_vec_init (tree base, tree maxindex, tree init,
>>>> }
>>>> }
>>>>
>>>> + /* Default-initialize scalar arrays directly. */
>>>> + if (TREE_CODE (atype) == ARRAY_TYPE
>>>> + && SCALAR_TYPE_P (TREE_TYPE (atype))
>>>> + && !init)
>>>
>>> This should check explicit_value_init._p rather than !init. And also
>>> check zero_init_p.
>>
>> Do you mean explicit_value_init_p && zero_init_p (atype)?
>
> Yes.
>
>> zero_init_p
>> doesn't sound like the correct thing to use here, because it doesn't
>> take into account whether a class array type has a constructor. I am
>> probably misunderstanding the purpose of the zero_init_p check,
>> though.
>
> Since you're already checking for scalar type, we don't need to worry
> about classes. The zero_init_p check is to handle pointers to data
> members properly.
Any update?
Jason