https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120163

            Bug ID: 120163
           Summary: Can not import module containig call to pure routine
                    via abstract interface
           Product: gcc
           Version: 15.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: baradi09 at gmail dot com
  Target Milestone: ---

GIVEN:
* A module defines an abstract interface for a pure subroutine
(callback_interface).
* Within the same module, a routine declares a dummy argument of the type
procedure(callback_interface).
* This routine internally calls the dummy procedure argument.
* The flag -Wall is turned on during compilation

WHEN:
* This module is imported into another module using a USE statement.

THEN:
* Compilation of the importing module fails with cryptic error message.

MINIMAL WORKING EXAMPLE:

File: test.f90
module mod1
  implicit none

  abstract interface
    pure subroutine callback_interface(a)
      real, intent(in) :: a
    end subroutine callback_interface
  end interface

contains

  subroutine caller(callback)
    procedure(callback_interface) :: callback
    real :: a
    call callback(a)
  end subroutine caller

end module mod1


module mod2
  use mod1
end module mod2


Compiling the code with

gfortran -c -Wall test.f90

EXPECTED BEHAVIOR

Code compiles without any warnings.

OBSERVED BEHAVIOR

Compilation aborts due to error message:

test.f90:22:6:

   22 |   use mod1
      |      1
Error: Argument ‘_formal_0’ of pure subroutine ‘callback’ at (1) must have its
INTENT specified or have the VALUE attribute
test.f90:22:6:

   22 |   use mod1
      |      1
Error: Argument ‘_formal_0’ of pure subroutine ‘callback’ at (1) must have its
INTENT specified or have the VALUE attribute

Reply via email to