This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix PR C++/28906, fallout from the fix for PR 27184
- From: Andrew Pinski <pinskia at physics dot uc dot edu>
- To: jason at redhat dot com (Jason Merrill)
- Cc: pinskia at physics dot uc dot edu (Andrew Pinski), gcc-patches at gcc dot gnu dot org
- Date: Thu, 7 Sep 2006 13:34:41 -0400 (EDT)
- Subject: Re: [PATCH] Fix PR C++/28906, fallout from the fix for PR 27184
>
> Andrew Pinski wrote:
> > - full_type = build_cplus_array_type (type, NULL_TREE);
> > index = convert (sizetype, nelts);
> > index = size_binop (MINUS_EXPR, index, size_one_node);
> > - TYPE_DOMAIN (full_type) = build_index_type (index);
> > + index = build_index_type (index);
> > + full_type = build_cplus_array_type (type, NULL_TREE);
> > + /* We need a copy of the type as build_array_type will return a shared copy
> > + of the incomplete array type. */
> > + full_type = build_distinct_type_copy (full_type);
> > + TYPE_DOMAIN (full_type) = index;
>
> Why not just pass the index type to build_cplus_array_type?
Because we will then reject the following valid code:
int n;
int *x = new int[n];
as the middle-end thinks we are creating a VLA out side of
a function as we have not set up the function to hold non constant
initializers yet.
Thanks,
Andrew Pinski