Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!usc!cs.utexas.edu!uwm.edu!rpi!batcomputer!lijewski From: lijewski@batcomputer.tn.cornell.edu (Mike Lijewski) Newsgroups: comp.lang.c Subject: Correct parsing of ternary operator. Keywords: ternary conditional parsing Message-ID: <9493@batcomputer.tn.cornell.edu> Date: 3 Jan 90 23:21:31 GMT Distribution: comp Organization: Cornell National Supercomputer Facility Lines: 35 Consider the following code: main() { int a = 0, b = 1, c = 2; c ? c = a : c = b; exit(0); } According to the precedence rules of C, the conditional expression should be evaluated as: (c ? c = a : c) = b; which should produce and error. Well, it happens that I have a compiler which accepts this and produces results which suggest to me that it is evaluating this expression as: c ? c = a :(c = b); The vendor seems unwilling to accept this as a bug. Am I just being pedantic, or is this a serious bug? I haven't been able to come up with an example of correct usage of the ternary operator, which produces incorrect code. If anyone knows of some code which might clearly prove that this is a bug, I would sure appreciate receiving it. Thanks. -- Mike Lijewski (H)607/277-7623 (W)607/255-0539 (desk)607/255-2960 Cornell National Supercomputer Facility ARPA: mjlx@cornellf.tn.cornell.edu BITNET: mjlx@cornellf.bitnet SMAIL: 1122 Ellis Hollow Rd. Ithaca, NY 14850