Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!tut.cis.ohio-state.edu!unmvax!gatech!mcnc!spl From: spl@mcnc.org (Steve Lamont) Newsgroups: comp.lang.c Subject: Re: still problems with ?: Message-ID: <4683@alvin.mcnc.org> Date: 9 Jun 89 19:07:09 GMT References: <2632@solo1.cs.vu.nl> <562@lakart.UUCP> <4675@alvin.mcnc.org> <10387@smoke.BRL.MIL> Reply-To: spl@mcnc.org.UUCP (Steve Lamont) Organization: Microelectronics Center of NC; RTP, NC Lines: 30 In article <10387@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn) writes: >In article <4675@alvin.mcnc.org> spl@mcnc.org.UUCP (Steve Lamont) writes: >>>((a = *p++) && e2 ) || (!a && e3) >>Is right to left evaluation mandated in this case? It seems to me that >> [my paranoia deleted to save embarrassment] >There has never been any ambiguity about the correct sequence of >operations during evaluation of such an expression (except when >`p' is used in `e2' or `e3'). The outermost operator is ||; to >evaluate ex1||ex2 the compiler is obliged to generate code that Right. The FM (K&R, First Edition, p. 19) sez: "Expressions connected by && or || are evaluated from left to right, and it is guaranteed that evaluation will stop as soon as truth or falsehood is known." I should've looked before posting. The thing I like about this group is the sense of humility it brings to me! >existing C source code. I don't think you really need to guard >against totally broken compilers; if you start worrying about that, >there is no end to the things that "might" be done wrong.. Don't know if I exactly agree with that. I've *had* to use some fairly broken compilers... :-) -- spl Steve Lamont, sciViGuy EMail: spl@ncsc.org North Carolina Supercomputing Center Phone: (919) 248-1120 Box 12732/RTP, NC 27709