Path: utzoo!attcan!uunet!lll-winken!ames!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn ) Newsgroups: comp.lang.c Subject: Re: Broken compilers? (was Re: Comma Operator) Message-ID: <9382@smoke.BRL.MIL> Date: 15 Jan 89 00:07:40 GMT References: <922@quintus.UUCP> <1904@buengc.BU.EDU> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 21 In article <1904@buengc.BU.EDU> bph@buengc.bu.edu (Blair P. Houghton) writes: -> printf("%d %d %d\n", (x = 1, y = 2), x, y); >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? The second reduction is of course equivalent to the first. However, both are broken (assuming x or y is used afterwards), because after the statement containing printf(), x is required to contain the value 1 and y must contain the value 2. Leaving their contents unchanged is not permitted (unless the program cannot detect it, e.g. if their values are afterwards unused). >I mean, the assignment itself is not an expression per se, but a statement, No, assignments are expressions, not statements. Sticking a semicolon after an expression turns it into a statement.