Re: Is the order of parse '?:' operator not defined?

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

 



Dmitry K. wrote:

> Is the abort of program below correct?

I think it 's a bug.  Forwarding to Tom tromey for comment.

Andrew.


> /* 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 ();
> }
> 


[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