Hello Paul. All the best for 2013 to you and the people at Silverfrost
I'm sorry, I haven't been clear.
The code above is valid Fortran 95 code. (I haven't made a programming error). In the standard it says that indices used in FORALL statements and constructs have the [u:c2a31790e9]scope[/u:c2a31790e9] of the FORALL statement or construct only, and do not affect or inherit attributes from other variables in scope that happen to have the same name.
The Fortran Handbook, J Adams et.al. specifically describes the case I have coded above where the index i has the same name as a dummy argument with the INTENT(IN) attribute as legal code.
The BUG is that an 'Access Violation' error occurs at run-time when I run the code compiled with /CHECKMATE.
The code compiles and runs correctly in release mode, as I would expect.
The problem is similar to the one on nesting a FORALL inside a DO loop in the other thread.
I don't know how you are handling FORALL index scope in your compiler. One way to do it is to internally pre-pend some 'illegal' character (e.g. @) to the index names in FORALL statements so the above code looks like the following internally. This will work even for nested FORALLs (where the FORALL scope is shared in the nest). I assume you are doing something like this anyway, since the code works fine in release mode.
subroutine xxx(i)
integer, intent(in) :: i
real a(5)
! integer @i is reserved on the stack or held in a register
forall(@i=1:5) a(@i) = @i
print *, a
print *, i
end subroutine xxx
program anon
call xxx(1)
end