Path: utzoo!attcan!uunet!lll-winken!ames!mailrus!iuvax!purdue!bu-cs!buengc!bph From: bph@buengc.BU.EDU (Blair P. Houghton) Newsgroups: comp.lang.c Subject: Broken compilers? (was Re: Comma Operator) Message-ID: <1904@buengc.BU.EDU> Date: 14 Jan 89 19:31:39 GMT References: <922@quintus.UUCP> Reply-To: bph@buengc.bu.edu (Blair P. Houghton) Followup-To: comp.lang.c Organization: Boston Univ. Col. of Eng. Lines: 33 In article <922@quintus.UUCP> nair@quintus () writes: >What should this print? > > int x, y; > printf("%d %d %d\n", (x = 1, y = 2), x, y); I've emailed the conforming answer. (I fixed the obvious typo, too). Now, on to controversy. A while back, someone indicated that they knew of a compiler optimizer that would reduce something such as the above (ostensibly through constant-reduction) to printf("%d %d %d\n", (1,2), x, y); or maybe even printf("%d %d %d\n", 2, x, y); So, you compiler-writing C-programmers, is this thing broken or what? I mean, the assignment itself is not an expression per se, but a statement, and comma operators deal in expressions. But then, the assignment operators are operators, and in this case hold a place up there with functions in that they are expressions that can become statements with just the concatenation of a semicolon. It's in the syntax description. So, "broken?" "Not Broken?" "Not worth the display phosphorescence energy?" What? --Blair "I'm broke, too, but that's not in the syntax description..."