linux-gcc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* GCC 3.3.2: Some bug in the preprocessor?
@ 2004-02-12 20:29 Denis Zaitsev
  2004-02-12 20:34 ` Zack Weinberg
  0 siblings, 1 reply; 3+ messages in thread
From: Denis Zaitsev @ 2004-02-12 20:29 UTC (permalink / raw)
  To: gcc, linux-gcc

Look, this defun returns 0, and this is correct:

tst()
{
#if (unsigned)0 > -1
    return 1;
#else
    return 0;
#endif
}

But this one returns 1, and this is incorrect:

tst()
{
#if 0 > (unsigned)-1
    return 1;
#else
    return 0;
#endif
}

What's wrong?

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

* Re: GCC 3.3.2: Some bug in the preprocessor?
  2004-02-12 20:29 GCC 3.3.2: Some bug in the preprocessor? Denis Zaitsev
@ 2004-02-12 20:34 ` Zack Weinberg
  2004-02-12 20:44   ` Denis Zaitsev
  0 siblings, 1 reply; 3+ messages in thread
From: Zack Weinberg @ 2004-02-12 20:34 UTC (permalink / raw)
  To: gcc; +Cc: linux-gcc


You cannot use casts in #if.  Your conditionals are read as

#if (0)0 > -1

which produces a syntax error;

#if 0 > (0)-1

which evaluates as 0 > 0 - 1 which is true.

zw

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

* Re: GCC 3.3.2: Some bug in the preprocessor?
  2004-02-12 20:34 ` Zack Weinberg
@ 2004-02-12 20:44   ` Denis Zaitsev
  0 siblings, 0 replies; 3+ messages in thread
From: Denis Zaitsev @ 2004-02-12 20:44 UTC (permalink / raw)
  To: Zack Weinberg; +Cc: gcc, linux-gcc

On Thu, Feb 12, 2004 at 12:34:04PM -0800, Zack Weinberg wrote:
> 
> You cannot use casts in #if.  Your conditionals are read as
> 
> #if (0)0 > -1
> 
> which produces a syntax error;

Oh, ok, thanks.  I've missed the error message...

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

end of thread, other threads:[~2004-02-12 20:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-02-12 20:29 GCC 3.3.2: Some bug in the preprocessor? Denis Zaitsev
2004-02-12 20:34 ` Zack Weinberg
2004-02-12 20:44   ` Denis Zaitsev

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 NNTP newsgroup(s).