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: Nathan Froyd <nfroyd at mozilla dot com>
- To: Jason Merrill <jason at redhat dot com>
- Cc: gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 17 Nov 2017 23:04:55 -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>
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)? 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.
-Nathan