comp.lang.ada
 help / color / mirror / Atom feed
From: awdorrin <awdorrin@gmail.com>
Subject: GNAT 4.4.5 order of conditional processing?
Date: Tue, 15 Nov 2011 12:30:07 -0800 (PST)
Date: 2011-11-15T12:30:07-08:00	[thread overview]
Message-ID: <fedec493-c81e-4bc9-ba94-399028221f77@k26g2000yqd.googlegroups.com> (raw)

Given an IF statement such as the following:

if X = Y and not A and B

How does GNAT handle the processing of the conditional statements?
Will "X = Y" be processed first, and if false, will the rest be
skipped?

Reason I'm asking is I'm porting code, and it appears as if all of the
statements are being evaluated, even though the "X = Y" part is
already false.

I'm not sure if there is some optimization going on and if there is,
is there a compiler flag to disable it.

Guessing the best thing to do would be to rewrite the code to
something clearer like:

if X = Y then
  if not A then
   if B then ...

But I was curious since this is something that is probably a hundred
places through out this collection of source code.

Thanks
-Al



             reply	other threads:[~2011-11-15 20:37 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-15 20:30 awdorrin [this message]
2011-11-15 20:54 ` GNAT 4.4.5 order of conditional processing? Niklas Holsti
2011-11-15 21:07   ` awdorrin
2011-11-15 21:23     ` Vinzent Hoefler
2011-11-15 21:49       ` awdorrin
2011-11-16 21:31         ` Gautier write-only
2011-11-16 22:40           ` Adam Beneschan
2011-11-17  0:00             ` Adam Beneschan
2011-11-15 23:08 ` Jeffrey Carter
2011-11-16  1:18   ` Adam Beneschan
2011-11-16  5:33     ` tmoran
2011-11-16 17:52       ` awdorrin
2011-11-16 20:01         ` Simon Wright
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox