2018-06-28 13:05 GMT+02:00 N.M. Maclaren <n...@cam.ac.uk>: > On Jun 28 2018, Janus Weil wrote: >> >> >>> if we add a warning, we should add it both for >>> >>> if (flag .and. func()) >>> and for >>> if (func() .and. flag) >>> >>> because the standard also allows reversing the test (which my >>> original test did). >> >> >> well, I really don't want to warn for hypothetical problems. Since we >> currently do not apply such an optimization, we should not warn about >> it (unless you find any other compiler which actually does). > > > I have used such compilers; they used to be fairly common and may still be.
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 agree with Thomas, and think it should be in -Wextra. -Wsurprising is in > -Wall, and this is done in so many programs (usually with not-pure functions > that are actually pure, or effectively so) that the number of warnings would > put people off using -Wall. I agree that -Wextra might be more suitable than -Wall. 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.) Regarding warnings for "if (func() .and. flag)", I would like to have a very concrete reason, otherwise it will not be very useful. Which other compilers optimize this call away? Thanks for the constructive comments! Cheers, Janus