[Bug fortran/31269] short-circuit in -fbounds-check

tobi at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Tue Mar 20 19:11:00 GMT 2007



------- 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



More information about the Gcc-bugs mailing list