http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54556
--- Comment #8 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-09-12 21:00:32 UTC --- Test case: Compile in two files with -O0/-O1/-O2/ give the expected i == 5 but using -O3 hoists the "i = s(x)" out of the loop and thus gives i == 1. Question: Why is IMPLICIT_PURE set. For a PURE function, one gets: Variable 'x' can not appear in a variable definition context ! ------ FILE 1 ---------- module m type t integer :: i = 0 end type t contains integer function s(x) type(t), pointer :: x x%i = x%i + 1 s = x%i end function s end module m ! ------- FILE 2 ---------- use m type(t), pointer :: x integer :: i, j, k allocate(x) x%i = 0 do k = 1, 5 i = s(x) end do print *, i if (i /= 5) call abort () end