Skip to contentSkip to conversation

GCC 3.3.2: Some bug in the preprocessor?

DISCUSSION Denis Zaitsev 2 participants 3 messages Feb 12, 2004

lore
Share & tools
lore
#0 lore raw

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?

#1 lore raw

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

#2 lore raw
Quoted 6 lines · Zack Weinberg

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...