This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/85599] Prevent short-circuiting of logical expressions for non-pure functions
- From: "janus at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 17 May 2018 13:48:18 +0000
- Subject: [Bug fortran/85599] Prevent short-circuiting of logical expressions for non-pure functions
- Auto-submitted: auto-generated
- References: <bug-85599-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85599
--- Comment #29 from janus at gcc dot gnu.org ---
(In reply to Thomas Koenig from comment #27)
> > If an impure function is found (recursively) in the operands of an .AND.
> > expression, issue a
> >
> > gfc_warning(OPT_Wsurprising, "Impure function %qs at %L may not be
> > evaluated", ...)
> >
> > So,
> >
> > if (flag .and. f(x) > 0.)
> >
> > would also be warned about.
>
> I think I will start working on that warning; this should lead to
> users being made aware of a potential problem in their code.
That's not my favorite way of fixing it, but it's certainly an improvement upon
the current state of things, so I'm fine with it.
The warning text basically sounds good to me, although you could possibly
replace 'may' by 'might'. I'm not a native speaker, but I think that is clearer
and sounds less like "... is not allowed to be evaluated".
In addition to .and., a treatment of .or. is needed as well.