Am 14.06.2018 um 10:38 schrieb Janus Weil:
Also, there are AFAIU other similar weirdness with impure functions.
The
standard allows a compiler to optimize
y = f(x) + f(x)
into
y = 2 * f(x)
even if f is impure, which is totally bonkers. Or even not call f at
all,
if the compiler determines that y is not needed.
Yes, that is the same kind of craziness. I hope gfortran does not actually do
this?
I would vote for this, but currently it is not done unless
-faggressive-function-elimination is specified.
By the way, there is a bit of strangeness about this. People use -Ofast
knowing it will break all sorts of standards for numercial computation,
but they balk at using an optimization that is explicitly permitted
by the standard. Oh well...