Skip to content

Instantly share code, notes, and snippets.

@scivision
Last active June 1, 2025 19:26
Show Gist options
  • Save scivision/43841c17cc47dfaef2817a331a31c90a to your computer and use it in GitHub Desktop.
Save scivision/43841c17cc47dfaef2817a331a31c90a to your computer and use it in GitHub Desktop.
GCC Gfortran 15.1.0 new bug with -Wall flag

GCC Gfortran 15.1.0 has a new bug that is fixed in Gfortran 15.2.0 release on any operating system (Windows, macOS, ...) that is triggered by -Wall

gfortran -Wall wall.f90 && ./a.out

wall.f90:38:12:

38 | call nexact(fprime) | 1 Error: Interface mismatch in dummy procedure 'fprime' at (1): Shape mismatch in argument '_formal_0'

This occurs regardless of the implied dimension(:) or specific (even dimension(1)) dimension of the parameter.

However, doing

gfortran wall.f90 && ./a.out

works and prints the expected "ok".

Working Fortran compilers

  • Flang 20.1.6: flang wall.f90 works ok--note that Flang doesn't have a -Wall like flag yet.
  • Intel oneAPI 2024.0, 2025.1: ifx -warn wall.f90 works OK

Working GFortran versions with gfortran -Wall wall.f90 include: 8.5.0, 9.3.0, 10.2.0, 11.2.0, 12.2.0, 13.2.0, 14.2.0

GCC's self-test for this issue: https://gcc.gnu.org/cgit/gcc/tree/gcc/testsuite/gfortran.dg/interface_60.f90?id=e7a2b8b76ae0c8f1e49c780aa82ebb5f0325f515

module mismatch
implicit none
private
public :: nexact, ofun
abstract interface
integer function ofun(parms)
integer, dimension(1), intent(in) :: parms
end function
end interface
contains
integer function nexact(fprime)
procedure(ofun), pointer, intent(in) :: fprime
integer, dimension(1) :: parms
parms = [1]
nexact = fprime(parms)
end function
end module
program main
use mismatch, only: ofun, nexact
implicit none
procedure(ofun), pointer :: fprime
integer :: i
fprime=>rpoly
i = nexact(fprime)
print '(a,i0)', 'expected 1, got ', i
contains
integer function rpoly(parms)
integer, dimension(1), intent(in) :: parms
rpoly = parms(1)
end function
end program
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment