This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: c++/9618: ternary operator does not associate properly


The following reply was made to PR c++/9618; it has been noted by GNATS.

From: Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
To: gpeters@deepsky.com
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: c++/9618: ternary operator does not associate properly
Date: 07 Feb 2003 23:38:45 +0100

 gpeters@deepsky.com writes:
 
 > #include <stdio.h>
 > int main( int c, char*v[])
 > {
 >     printf( "%d", 1?1:0?0:0);
 >     return 0;
 > }
 > 
 > the above program returns 1, the C++ standard associates the ?:
 > operator left to right, not right to left, and thus it should return
 > 0.  The binding being used is as for C.
 
 Are you sure? My standard says: "Conditional expressions group
 right-to-left." [5.16.1] Therefore, gcc's behaviour seems correct to
 me. It would also occur to me as very weird if C++ would intentionally
 break C compatibility here.
 
 -- 
 	Falk


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]