Is the order of parse '?:' operator not defined?
Dmitry K.
dmixm@marine.febras.ru
Sun Dec 21 17:47:00 GMT 2008
Hi,
Is the abort of program below correct?
Thanks,
Dmitry.
/* This program is aborted with GCC 3.4.6. Also it is checked that
'#if foo(1) == bar(1)' is evaluted as false with a set of 3.3 - 4.3
releases. Seems, the CPP and CC parsers are different in case of
foo() macro.
C99 standart:
6.5.15 Conditional operator
Syntax
conditional-expression:
logical-OR-expression
logical-OR-expression ? expression : conditional-expression
*/
extern void abort (void);
#define foo(x) ((x) & 1 ? 1 : (x) & 2 ? 2 : 0 )
#define bar(x) ((x) & 1 ? 1 : ((x) & 2 ? 2 : 0))
int main ()
{
#if foo (1) == bar (1)
return 0;
#endif
if (foo (1) != bar (1))
return 0;
abort ();
}
More information about the Gcc-help
mailing list