http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48031
--- Comment #9 from rguenther at suse dot de <rguenther at suse dot de> 2011-03-10 12:36:33 UTC --- On Thu, 10 Mar 2011, ebotcazou at gcc dot gnu.org wrote: > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48031 > > --- Comment #8 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2011-03-10 > 12:34:57 UTC --- > > It's mixing VLA unaware foldings into the mids of GIMPLE which is the > > root of the issue though. The issue is latent on trunk. > > > > Patch for the first (and safe) idea: > > > > Index: gcc/fold-const.c > > =================================================================== > > --- gcc/fold-const.c (revision 170818) > > +++ gcc/fold-const.c (working copy) > > @@ -15554,7 +15560,8 @@ fold_indirect_ref_1 (location_t loc, tre > > } > > /* *(foo *)&fooarray => fooarray[0] */ > > else if (TREE_CODE (optype) == ARRAY_TYPE > > - && type == TREE_TYPE (optype)) > > + && type == TREE_TYPE (optype) > > + && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST) > > { > > tree type_domain = TYPE_DOMAIN (optype); > > tree min_val = size_zero_node; > > @@ -15633,7 +15640,8 @@ fold_indirect_ref_1 (location_t loc, tre > > > > /* *(foo *)fooarrptr => (*fooarrptr)[0] */ > > if (TREE_CODE (TREE_TYPE (subtype)) == ARRAY_TYPE > > - && type == TREE_TYPE (TREE_TYPE (subtype))) > > + && type == TREE_TYPE (TREE_TYPE (subtype)) > > + && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST) > > { > > tree type_domain; > > tree min_val = size_zero_node; > > > > Eric, can you see any issues with that and Ada? > > If this is limited to the in_gimple_form case, probably none. No it isn't. But given that fold at this place doesn't even fill in the array-ref element-size slot but provides NULL_TREE it is probably a fix for the better anyway? Richard.