Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

The middle part of a Conditional Expression ( between ? and : ).

13 views
Skip to first unread message

Jeff-Relf.Me

unread,
May 27, 2017, 8:08:41 AM5/27/17
to
Speaking of C/C++...

The middle part of a Conditional Expression ( between ? and : )
is parsed as if parenthesized; for example:

  int rv, zz ;

  zz = 1, rv = zz ? zz = 1, 2 : zz = 3, 6 ;
  printf( L"%d and %d", rv, zz );  //  Prints: " 2 and 1 ".

  zz = 0, rv = zz ? zz = 1, 2 : zz = 3, 6 ;
  printf( L"%d and %d", rv, zz );  //  Prints: " 3 and 3 ".

  http://en.cppreference.com/w/c/language/operator_precedence

These expressions are undefined/SemiRandom:

  i = ++i + i++ ;
  i = i++ + 1 ;
  f( ++i, ++i );
  f( i = -1, i = -1 );
  f( i, i++ );
  a[ i ] = i++ ;

  http://en.cppreference.com/w/c/language/eval_order
0 new messages