2

I am wondering what is supposed to be the behavior of a fortran program that uses pointer variables as loop counts? For instance using gfortran, this program:

program foo
  integer, pointer :: x
  integer, target :: y
  x => y
  do x=0,10
    y = 100                                                                                                                                                                                                                   
    print*, "hello"
  enddo
end program

became an infinite loop when executed. Is that supposed to happen?

1 Answer 1

8

The example program is not standard conforming. You are not permitted to change the do variable in any way (F2008 8.1.6.6.2p3), which includes "behind the scenes" tricks using pointers.

Consequently anything is possible.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.