https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85599

--- Comment #25 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
(In reply to janus from comment #23)
> (In reply to Thomas Koenig from comment #21)
> > If we make guarantees that the standard does not, we will be
> > creating our own language
> 
> I certainly don't want to create my own language. I'm trying to use the
> freedom that the Fortran standard (unfortunately) gives in this area in a
> reasonable way.
> 
> 
> > (and people will get problems moving
> > code to another compiler).
> 
> We do have problems with compiler-dependent behavior already. The behavior
> I'm proposing is consistent with what ifort, PGI and flang do.

But that is something not guaranteed by the standard...

> 
> > Warn, yes.  This is the kind of thing that -Wsurprising is for,
> > so people will get something with -Wall. (I volunteer for that).
> 
> What do you want to warn about? And how?

A front end pass (what else did you expect? :-)

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.

> 
> > Optimize, yes.  This could also be integrated with the warning.
> 
> Optimize, yes, but not at the price of changing results.

Not against what the standard guarantees.

> > Change the language, no.
> 
> Agreed.

But that is what you are proposing - we would make a guarantee that
the standard does not make.

Reply via email to