[patch] builtins.c, fold-const.c: Don't create type mismatches.

Daniel Berlin dberlin@dberlin.org
Sat Apr 16 22:10:00 GMT 2005


On Sat, 2005-04-16 at 08:36 -0600, Roger Sayle wrote:
> Hi Kazu,
> 
> On Sat, 16 Apr 2005, Kazu Hirata wrote:
> > 2005-04-16  Kazu Hirata  <kazu@cs.umass.edu>
> >
> > 	PR middle-end/21024
> > 	* builtins.c (expand_builtin_strcat): Convert the result of
> > 	strlen to the right type.
> > 	* fold-const.c (fold_binary) <PLUS_EXPR>: Use fold_convert to
> > 	avoid creating type mismatches.
> > 	<GE_EXPR>: Pass op0 and op1 to fold_build2 to avoid creating
> > 	type mismatches.
> 
> This is OK for mainline.  Thanks.
> 
> I believe that Dan Berlin is currently working on a semantics document
> for GCC's tree codes. 


Yes. I believe others are as well.
It's been somewhat backburnered while i finish up 
1. Structure aliasing stuff
2. Helping honza merge the rest of tree-profiling
3. Finish my GCC summit paper (done soon).


The current constraint i have in place for binary gimple operators is
that both *operands* have the same type.
I have placed no such constraint on the result type, but this mainly
because it never occurred to me that it would be useful in some case to
have a result type different, so i assumed it would always be the same.

I don't believe i've met a compiler that allows the result type to be
different than the operation type (except for casts, obviously).
Though i'm more than happy to discuss al this.


(Besides obvious "type safety" issues with requiring both operands to be
the same type, it means in a perfect world, you no longer need to
actually *store the type of the operands* in that case.  Whether we can
do that anytime soon, i have no idea, but it's still a nice thought :P)




More information about the Gcc-patches mailing list