Hi Janne,
What about more complicated expressions like, say, "func() .and. flag .and func2() .and. flag2" etc.? Can it move all the function calls to the end?
Not at the moment. Like many of the front-end optimizations, this aims for the easy 80% which are relatively easy to achieve.
IMHO it's a mistake that the standard refuses to specify the evaluation strategy in the name of some rather minor hypothetical performance benefit.
Well, it is the way it is, and it is not going to change. We might as well make the best of the situation as it is. There are other standards, such as the C standard, whose type-based aliasing rules can be used for optimization, but can also introduce hard-to-find bugs. gcc's philosophy is to use the optimization possibilities, and I see no reason for gfortran to deviate from that. Regards Thomas