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

janus at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu May 17 09:44:00 GMT 2018


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

--- Comment #26 from janus at gcc dot gnu.org ---
(In reply to Thomas Koenig from comment #25)
> > 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...

Does not make too much difference in the end, does it? You still have code that
gives different results with different compilers, which is always a bad thing.

That's exactly why I think it was a bad decision for the standard to leave this
decision to the compiler.


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

Does. Not. Matter.

It is still an optimization that changes the end result, which is generally a
bad thing IMHO. Even if some standards document says "it's not illegal", I
would say "it's still a bad idea"!


> > > Change the language, no.
> > 
> > Agreed.
> 
> But that is what you are proposing - we would make a guarantee that
> the standard does not make.

Disagree. We wouldn't make a guarantee, we would just choose one of two
possible implementations that are allowed by the standard. That's not "changing
the language".


More information about the Gcc-bugs mailing list