On Jun 28 2018, Janus Weil wrote:
You mean compilers which transform "if (func() .and. flag)" into "if (flag .and. func())", and then possibly remove the call? If yes, could you tell us which compilers you are talking about specifically?
I am 70, and haven't supported multiple compilers for over a decade! No, I can't remember. If I recall, the most widespread optimising compiler of the 1980s did (IBM Fortran Q), as well as several others of that era. I can't remember which of those I have used recently did, because it was not something I looked at - I had known for ages that it was likely, so followed the simple rule that ANY function call might disappear. Yes, even in statements like X = FRED(), because the value of X might not be needed.
Btw, effectively pure functions which are not marked with the PURE attribute should hopefully not be a problem, since gfortran has implicit_pure detection that should deal with that. (However, it might need some further improvements, I think.)
Most practical programmers use external libraries, often supplied as binary. The only information the compiler can rely on is whether the function is marked as PURE. It's moot whether such a warning should rely on implicit pure detection, because the gotcha with doing so is the programmer modifies the function, adds a side-effect, does NOT recompile the calling code, and can't work out why nothing has changed! Been there - done that :-) Response to self on locating it: you IDIOT, Nick! Regards, Nick Maclaren.