From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,db5c6b2ef47d4b9e X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-06-20 16:04:26 PST Newsgroups: comp.lang.ada Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.mathworks.com!news.mathworks.com!uunet!ash.uu.net!xyzzy!nntp From: Jeffrey Carter Subject: Re: short-circuit control forms X-Nntp-Posting-Host: e246420.msc.az.boeing.com Content-Type: text/plain; charset=us-ascii Message-ID: <3B312495.15258B18@boeing.com> Sender: nntp@news.boeing.com (Boeing NNTP News Access) Content-Transfer-Encoding: 7bit Organization: The Boeing Company X-Accept-Language: en References: Mime-Version: 1.0 Date: Wed, 20 Jun 2001 22:32:53 GMT X-Mailer: Mozilla 4.5 [en]C-CCK-MCD Boeing Kit (WinNT; U) Xref: archiver1.google.com comp.lang.ada:8946 Date: 2001-06-20T22:32:53+00:00 List-Id: Ted Dennison wrote: > > I can't find anything in the LRM that says that compilers *can't* optimize away > unneeded conditions in the way you describe (any language lawyers in the > house?), but it wouldn't shock me to find loads of code that assumes it won't > happen. I'm not sure what the LRM's silence on a subject means in this case. But > assuming it means "all bets are off", then it looks to me like compilers are > perfectly free to short-circuit, or even reorder and short-circuit normal > conditional expressions. IANAL, nor do I play one on TV. However, "and" and "or" are normal subprograms (you can overload them), and the semantics for subprograms state that all actual parameters are evaluated, and the order of evaluation is not specified by the language (ARM 6.4). Thus, it is illegal for a compiler to convert them to short-circuit forms. -- Jeffrey Carter