This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/31269] short-circuit in -fbounds-check
- From: "tobi at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 20 Mar 2007 19:11:02 -0000
- Subject: [Bug fortran/31269] short-circuit in -fbounds-check
- References: <bug-31269-9375@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #10 from tobi at gcc dot gnu dot org 2007-03-20 19:11 -------
Mimo,
you rely on behavior that is not specified by the standard. It says explicitly
that only, in order to determine the value of an expression, only as much of it
needs to be evaluated, as is needed to determine the vlaue of the entire
expression. E.g. in "sqrt(x) + f(y)" f(y) needs not be executed if x is < 0.
The result will be NaN after all. But this doesn't mean that negative x
implies that f(y) won't be executed.
If you want sane behavior, the general rule is to follow the standard. Now I
personally think that, since we're using shortcut logic, it's perfectly sane
to, so to say, shortcut bounds checking as well. Other people have disagreed,
and they have strong arguments in their favor.
As for side-effects, one can easily come up with weird cases, which is why the
standard refrains from defining them. Think e.g. about
b .and. f(b) .and. b
where f may change its argument.
</rant>
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31269