This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Problems with ?: operator
- From: Sulabh Nangalia <sulabh dot nangalia at gmail dot com>
- To: gcc-help at gcc dot gnu dot org, gcc at gcc dot gnu dot org
- Date: Thu, 15 Dec 2005 13:01:48 +0530
- Subject: Problems with ?: operator
hi,
while compiling the following code on gcc v3.3 compiler (on mac os x),
i got the "invalid lvalue asignment" error as expected in the
following code:
main(){
int a = 1;
a < 10 ? a = 5 : a = 7;
return;
}
but i didn't get any error in
15 < 10 ? a = 5 : a = 7;
and
a < 10 ? a : a = 7;
5 < 10 ? a = 5 : a = 7; is giving error
15 < 10 ? a = 5 : a = 7; is not giving any error
why?
i am compiling using the following command:
$ cc -ansi -O0 file.c
all the syntaxes are wrong according to the ansi C grammar given in
"The C Programming Language" by Kernighan & Ritchie. then how come the
other 2 expressions are not giving compilation error.
when compiled on VC++, none of the expressions is giving error.
--
SULABH NANGALIA
Computer Science Engineer
Avisere
Mobile: +91 98300 29360