public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* problem with C++ keyword true
@ 2004-09-27 10:50 Steve Bliss
  2004-09-27 12:10 ` Claudio Bley
  0 siblings, 1 reply; 3+ messages in thread
From: Steve Bliss @ 2004-09-27 10:50 UTC (permalink / raw)
  To: gcc-help

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.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: problem with C++ keyword true
  2004-09-27 10:50 problem with C++ keyword true Steve Bliss
@ 2004-09-27 12:10 ` Claudio Bley
  0 siblings, 0 replies; 3+ messages in thread
From: Claudio Bley @ 2004-09-27 12:10 UTC (permalink / raw)
  To: gcc-help

On Mon, Sep 27, 2004 at 06:50:25AM -0400, Steve Bliss wrote:
> 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
> }
 
This works for me (tm). [GCC i386 3.4.1]

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

If that is so, yes this is a bug. You should probably get in touch with
the avr-gcc people on this (http://www.avr1.org/mailman/listinfo/avr-gcc-list/)
mailing list before filing a bug report here (http://gcc.gnu.org/bugzilla/).

--
Claudio 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: problem with C++ keyword true
@ 2004-09-27 16:24 lrtaylor
  0 siblings, 0 replies; 3+ messages in thread
From: lrtaylor @ 2004-09-27 16:24 UTC (permalink / raw)
  To: bliss1940-bbs, gcc-help

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@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org] On
Behalf Of Steve Bliss
Sent: Monday, September 27, 2004 4:50 AM
To: gcc-help@gcc.gnu.org
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.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-09-27 16:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-27 10:50 problem with C++ keyword true Steve Bliss
2004-09-27 12:10 ` Claudio Bley
2004-09-27 16:24 lrtaylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).