This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


On Thu, Apr 22, 2004 at 09:58:38AM -0400, Paul Koning wrote:
> >>>>> "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.

This is a case where C and C++ differ.  The type of the != operator is
bool in C++.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]