This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH][PR c++/82888] smarter code for default initialization of scalar arrays


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]