RE: problem with C++ keyword true

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Well, that may be a bug.  Than again, if this is a large program (and
you didn't write all of it), I'm wondering if someone went and #define'd
true, overriding the C++ definition of it...

Also, don't forget that you don't actually have to do the comparison.
You can simply do this:

if (george)
{
<snip>

If george evaluates to any non-zero value, it will be considered to be
true.

Thanks,
Lyle


-----Original Message-----
From: gcc-help-owner@xxxxxxxxxxx [mailto:gcc-help-owner@xxxxxxxxxxx] On
Behalf Of Steve Bliss
Sent: Monday, September 27, 2004 4:50 AM
To: gcc-help@xxxxxxxxxxx
Subject: problem with C++ keyword true

I'm using avr-gcc version 3.4.1 to compile C++.

Here's the problem:

bool george = true;

if(george == true)
{
   // never gets here
}
else
{
   // always gets here
}


In other words, the expression (george == true) is always false.  Isn't
this
a compiler bug?

For whatever it's worth, the value of george is 0x01 and the value of
true
seems to be 0xff.




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux