[tree-ssa] Why are bools cast to int in conditionals?

Paul Koning pkoning@equallogic.com
Thu Apr 22 14:28:00 GMT 2004


>>>>> "Joseph" == Joseph S Myers <jsm@polyomino.org.uk> writes:

 Joseph> On Wed, 21 Apr 2004, Dan Nicolaescu wrote:
 >> > Here, the usual arithmetic conversions are applied to the
 >> operands of !=, > which includes the integer promotions, which
 >> promote _Bool to int.
 >> 
 >> Is _Bool different from other types in this respect? short, chars
 >> and enums don't seem to get the same treatment.

 Joseph> Perhaps some optimization is allowing INTEGER_TYPE but not
 Joseph> BOOLEAN_TYPE.  Various optimizations of operations on
 Joseph> promoted types are presently in build_binary_op and
 Joseph> shorten_compare.

The trouble with that is that promotion to int is in fact
language-specific -- C/C++ may define things that way, but most other
high level languages don't.  Not that modula-3 or pascal is a high
visibility front-end, but I don't think that viewing this issue as
language-INdependent is right.

	     paul




More information about the Gcc mailing list