[Bug middle-end/85599] Function need not be evaluated in logical expression

janus at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed May 9 10:26:00 GMT 2018


janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=57160

--- Comment #14 from janus at gcc dot gnu.org ---
(In reply to Dominique d'Humieres from comment #10)
> Am I mistaken to read this as being handled by the middle-end?

The short-circuiting is finally handled by the middle end, since the front end
translates .and. into &&. See also comment 6.

Apparently the standard does neither require nor forbid the short-circuiting
(see c.l.f. discussion), but I would argue that it would be a more reasonable
for gfortran to avoid the short-circuiting (by translating to &), at least if
it is not clear whether the function has side effects.

> If yes, the
> situation is discussed in pr57160 comment 1.

Right, this PR is very much related.

> Does it means that 'check' has to be evaluated in
> if (flag) flag = check ()
> even if flag==.false. ?

No, I'm pretty sure that is not the case.

More information about the Gcc-bugs mailing list