This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/85599] Prevent short-circuiting of logical expressions for non-pure functions


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]