Hello, I'm exploring Fortran 2008, having done most of my Fortran in IV and 77, and some on 90/95 more recently. In exploring optional arguments I have come to this case, where testing the results of the example in the GNU Fortran manual for PRESENT works, until I add WRITE statements. When I add them the program hangs.
[machine name and path elided from the copy and paste below] $ make gfortran -o test_present_with_select.exe -Wall -Wextra -Wargument-mismatch -Wcompare-reals -Wdeprecated -Wdo-subscript -Wmisleading-indentation -Woverflow -Wsuggest-attribute=pure -Wunused -Wzerotrip test_present_with_select.f08 -lm gfortran -o test_present_with_select2.exe -Wall -Wextra -Wargument-mismatch -Wcompare-reals -Wdeprecated -Wdo-subscript -Wmisleading-indentation -Woverflow -Wsuggest-attribute=pure -Wunused -Wzerotrip test_present_with_select2.f08 -lm $ ls Makefile test_present_with_select2.exe test_present_with_select.exe test_present_with_select2.f08 test_present_with_select.f08 $ ./test_present_with_select.exe F T $ ./test_present_with_select2.exe [<ctrl-C> pressed here] $ cat -n test_present_with_select.f08 1 PROGRAM test_present 2 WRITE(*,*) f(), f(42) ! "F T" 3 CONTAINS 4 LOGICAL FUNCTION f(x) result(answer) 5 INTEGER, INTENT(IN), OPTIONAL :: x 6 call g(present(x), answer) 7 END FUNCTION 8 9 subroutine g(x, y) 10 logical, intent(in) ::x 11 logical, intent(out)::y 12 select case(x) 13 case(.true.) 14 y = .true. 15 case(.false.) 16 y = .false. 17 end select 18 end subroutine 19 END PROGRAM $ cat -n test_present_with_select2.f08 1 PROGRAM test_present 2 WRITE(*,*) f(), f(42) ! "F T" 3 CONTAINS 4 LOGICAL FUNCTION f(x) result(answer) 5 INTEGER, INTENT(IN), OPTIONAL :: x 6 call g(present(x), answer) 7 8 END FUNCTION 9 10 subroutine g(x, y) 11 logical, intent(in) ::x 12 logical, intent(out)::y 13 select case(x) 14 case(.true.) 15 y = .true. 16 write (*,*) "true" 17 case(.false.) 18 y = .false. 19 write (*,*) "false" 20 end select 21 end subroutine 22 END PROGRAM $ I obtained the same results when I used the compiler from the mingw site. I've not put Cygwin on here, so have not tried it. (I used the -n option of cat to make the discussion of where my bug is a bit easier, hopefully that won't make it too annoying to reproduce.) I can't square getting no errors from the compiler with the different results. If I've done something basically wrong here, I'd have expected it to have been picked up with these warning options. I'm running Windows 10 on an Intel Core-i5 system with 8GB of ram, if that helps. Can someone see why I'm barking up the wrong tree here? Is this even reproducible by other people? I'm reluctant to hypothesize a compiler bug, and I don't have any other (non-gnu) compilers with which to falsify that, so it would be superstition, not science 🙂 Thank you, Hugh
_______________________________________________ Msys2-users mailing list Msys2-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/msys2-users