Silverfrost Forums

Welcome to our forums

Possible (minor) bug

3 May 2023 10:53 #30264

With FTN95 the following code executes both the write statements in sub1. This is incorrect as access to the functions compiler_version() and compiler_options() from iso_fortran_env should be prevented by the ONLY statement.

module t_mod
use iso_fortran_env, only : INT8
implicit none
contains
  subroutine sub1
    write(6,'(/A,1X,I1)') 'Kind number of a 8  bit integer is', int8
    write(6,'(/A,1X,A)') 'Compiled with',   compiler_version()
    write(6,'(/A,1X,A)') 'Compiler options',compiler_options()
  end subroutine sub1
end module t_mod

program main
use t_mod
  call sub1
end program main

Fortunately this error appears to relate only to the functions in iso_fortran_env, and it is not apparent in the general case with user written code. FTN95 behaves as expected in the following example, i.e. sub1 has no access to function f2.

module a_mod
implicit none
contains
  integer function f1()
   f1 = 1
  end function f1
  
  integer function f2()
    f2 = 2
  end function f2
end module a_mod

module b_mod
use a_mod, only : f1
implicit none
contains
  subroutine sub1
    write(6,*) f1()
    write(6,*) f2()
  end subroutine sub1
end b_mod

program main
use b_mod
  call sub1
end program main
3 May 2023 11:14 #30266

Thanks Ken. I have made a note of this.

7 May 2023 7:41 #30276

This has now been fixed. It affects FTN95 and also the content of the iso_fortran_env module.

Please login to reply.