Temporary arrays in array assignment in presence of pointers

Thanks @pmk for replying. I could not write an example that causes the results of flang and gfortran (without temporary arrays) to differ.

I am thinking that gfortran is probably right here since even if val1 aliases with val2, it does not matter. The evaluation of the array assignment expression here depends only on a single value in val1, i.e. val1(i). As long as this value is read and stored in a register/temporary location, even if val1(i) is written into during the evaluation of the array assignment it is fine and the results do not change. For val2 the lhs and rhs refer to the same section and indices, so each element can be multiplied by val1(i) and updated in place without a temporary array I guess.