Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/5/84; site ism780c.UUCP Path: utzoo!watmath!clyde!burl!ulysses!bellcore!decvax!hplabs!sdcrdcf!ism780c!tim From: tim@ism780c.UUCP (Tim Smith) Newsgroups: net.lang.c Subject: Re: A simple non-portable expression tha Message-ID: <1916@ism780c.UUCP> Date: Mon, 21-Apr-86 20:37:19 EST Article-I.D.: ism780c.1916 Posted: Mon Apr 21 20:37:19 1986 Date-Received: Wed, 23-Apr-86 22:48:52 EST References: <130@brl-smoke.ARPA> Reply-To: tim@ism780c.UUCP (Tim Smith) Organization: Interactive Systems Corp., Santa Monica, CA Lines: 26 When I ask various people about what compilers can do to LONG + INT1 + INT2 I get two different answers. The first is that the compiler can play games with associativity and commutativity before it changes the ints to longs. The second is that it must change INT2 to a long because of the left associative nature of addition. Then it can use associativity and commutativity to change things. Reading K&R, I can convince myself of either answer. If the first case is correct, then this is a non-portable expression, and I think lint should warn about it. In the second case, there is no problem with that expression, but how about this one: INT1 + INT2 + LONG I should have used this one in my original posting. On a machine with different sizes for ints and longs, this expression can have problems. Lint says nothing about this. Is this a problem with lint, or am I (again) putting my foot in my mouth? -- Tim Smith sdcrdcf!ism780c!tim || ima!ism780!tim || ihnp4!cithep!tim