RFA (fold): PATCH for c++/49290 (folding *(T*)(ar+10))

Richard Guenther rguenther@suse.de
Tue Jun 7 13:49:00 GMT 2011


On Tue, 7 Jun 2011, Michael Matz wrote:

> Hi,
> 
> On Tue, 7 Jun 2011, Richard Guenther wrote:
> 
> > > > fold_convert_loc it to the expected type, while the middle-end has 
> > > > the notion of useless type conversions, fold-const.c is also used by 
> > > > FEs and I think it is expected to have the types exactly matching. 
> > > > So (T)s1[10] instead of s1[10] in this case.
> > > 
> > > I'm not sure that's a good idea if the caller wants an lvalue.
> > 
> > Rather build the array-ref with type T directly (thus, with a mismatch 
> > between the type of the array-ref and the element type).
> 
> Ick.  Sooner or later such inconsistency will bite us.  It always does.

There are already some similar "weak" type matchings done in fold-const.c.

But yeah ... I'm sure adding strong type checks to the tree checker
will detect may pre-existing inconsistencies...

Richard.



More information about the Gcc-patches mailing list