Hi,

> My Fortran project is based on -std=f2008. The  GNU Fortran (For GCC version 
> 15.0.0) manual’s 8.260 STAT example does not link if -std=f2008 is on the 
> command line: gfortran -std=f2008 test_stat.f90; ./a.out
> The ld error is “undefined reference to `stat_’”

Our doc (https://gcc.gnu.org/onlinedocs/gfortran/STAT.html) states: "Standard: 
GNU extension”

If you compile with -std=f2008 (or any other -std value except gnu or legacy), 
the STAT intrinsic is not available. Nor is CTIME. If you compile with -W 
-Wall, you will get helpful warnings about this:

test_stat.f90:5:21:

    5 |             CALL STAT("/etc/passwd", buff, status)
      |                     1
Warning: The intrinsic 'stat' at (1) is not included in the selected standard 
but a GNU Fortran extension and 'stat' will be treated as if declared EXTERNAL. 
 Use an appropriate '-std=' option or define '-fall-intrinsics' to allow this 
intrinsic. [-Wintrinsics-st]
test_stat.f90:5:21: Warning: The intrinsic 'stat' at (1) is not included in the 
selected standard but a GNU Fortran extension and 'stat' will be treated as if 
declared EXTERNAL.  Use an appropriate '-std=' option or define 
'-fall-intrinsics' to allow this intrinsic. [-Wintrinsics-std]
test_stat.f90:5:50:

    5 |             CALL STAT("/etc/passwd", buff, status)
      |                                                  1
Warning: The intrinsic 'stat' at (1) is not included in the selected standard 
but a GNU Fortran extension and 'stat' will be treated as if declared EXTERNAL. 
 Use an appropriate '-std=' option or define '-fall-intrinsics' to allow this 
intrinsic. [-Wintrinsics-st]
test_stat.f90:16:75:

   16 |               WRITE (*, FMT="('Last access time:',        T30, A19)") 
CTIME(buff(9))
      |                                                                         
  1
Warning: The intrinsic 'ctime' at (1) is not included in the selected standard 
but a GNU Fortran extension and 'ctime' will be treated as if declared 
EXTERNAL.  Use an appropriate '-std=' option or define '-fall-intrinsics' to 
allow this intrinsic. [-Wintrinsics-std]
test_stat.f90:16:75: Warning: The intrinsic 'ctime' at (1) is not included in 
the selected standard but a GNU Fortran extension and 'ctime' will be treated 
as if declared EXTERNAL.  Use an appropriate '-std=' option or define 
'-fall-intrinsics' to allow this intrinsic. [-Wintrinsics-std]
test_stat.f90:16:69:

   16 |               WRITE (*, FMT="('Last access time:',        T30, A19)") 
CTIME(buff(9))
      |                                                                     1
Warning: The intrinsic 'ctime' at (1) is not included in the selected standard 
but a GNU Fortran extension and 'ctime' will be treated as if declared 
EXTERNAL.  Use an appropriate '-std=' option or define '-fall-intrinsics' to 
allow this intrinsic. [-Wintrinsics-std]



Best,
FX

Reply via email to