Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!cmcl2!brl-adm!umd5!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.c Subject: Re: Possible C Anomaly Message-ID: <8554@mimsy.UUCP> Date: Sat, 12-Sep-87 22:32:44 EDT Article-I.D.: mimsy.8554 Posted: Sat Sep 12 22:32:44 1987 Date-Received: Sun, 13-Sep-87 10:48:52 EDT References: <9236@brl-adm.ARPA> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 25 In article <9236@brl-adm.ARPA> gamma@EDN-UNIX.arpa (W. J. Showalter) writes: > k = (k > 1) ? k-- : 1; >... According to K&R, the above expression is equivalent to > if (k > 1) > k = k--; > else > k = 1; >... The problem is is that the two examples behave differently. This is a case of `you are not supposed to do that!'. The two expressions are equivalent, and the second form is not defined: k = k--; like a[i] = i--; is simply not defined in C. Since the second form is not defined, neither is the first. A really good compiler would complain. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris