[patch, fortran] Fix PR29458 - spurious warning for implied do-loop counter
Daniel Franke
franke.daniel@gmail.com
Sun Apr 5 13:54:00 GMT 2009
On Sunday 05 April 2009 15:36:45 you wrote:
> Excuse my ignorance, but what should happen if the user did:
> integer :: n, i
> n = 5
> n = sum((/(i,i=1,n)/))
> print *, i
> end
> That should print 5, shouldn't it?
Then there would have been no need to save-off the value of 'i' in the first
place (which would have avoided the warning as well).
I don't have the standard ready, but MR&C state (section 6.16, paragraph
before the last):
"The scope of the variable [here i] is the constructor-implied-do. Other
statements, or even other parts of the array constructor, may refer to another
variable having the same name. The value of the other variable is unaffected
by execution of the array constructor and is available except within the
constructor-implied-do"
Thus, after the implied do-loop, 'i' is still undefined.
Cheers
Daniel
More information about the Gcc-patches
mailing list