program test
integer :: n
real :: res
real, allocatable :: x(:)
n = 1000
allocate(x(n), source = 1.0)
res = 0.0
block
integer :: i
do i = 1, n
res = res + x(i)
end do
end block
print *, i
print *, res
end program
Why is this code not producing any error/warning message in GFortran? I thought variables defined within a block are treated as undefined outside of the block.