This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch, fortran] Fix PR29458 - spurious warning for implied do-loop counter


Daniel Franke wrote:
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.

Yes, now that you say it I remember this feature of implied-do-loops.


Thanks & cheers,
- Tobi


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]