Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!seas.gwu.edu!xc215119 From: xc215119@seas.gwu.edu (David E. O'Brien) Newsgroups: comp.lang.c Subject: Re: What does ANSI C say about short circuit evaluation? Message-ID: <3229@sparko.gwu.edu> Date: 26 May 91 02:05:47 GMT References: <1991May22.092404.25297@ucthpx.uct.ac.za> Reply-To: xc215119@seas.gwu.edu () Organization: The George Washington University, Washington D.C. Lines: 18 In article <1991May22.092404.25297@ucthpx.uct.ac.za> gram@uctcs.uucp (Graham Wheeler) writes: >The following question has caused a bit of debate here in the last couple of >days. There are two parts: > >i) Does ANSI C say that compilers can rearrange the order of expression > evaluation? > >ii) Does it say that Boolean expressions must be evaluated with short- > circuit evaluation? > Yes, ANSI C requires boolean short circuiting and that the C compiler must process if(...) in the order from left to right. In fact you can read this from K & R 2nd ed. They even say that many, many C programmers DEPEND on this fact and in your life as a programmer you are probably going to come upon some code that depends on this, so get used to it. -- David O'Brien