The code class_assign_1.f08 makes inappropriate use of the MODULE attribute in several places (there are no submodules involved here). In addition, the abstract interface for base_add needs to import the derived type base; the interface body is a separate scoping unit and doesn't know anything about base otherwise (this suggests gfortran has a bug here).
With this diff the code compiles and runs cleanly with NAG 6.1 and Intel 18.0.1
diff --git a/class_assign_1.f08 b/class_assign_1.f08
index fb1f655..3d4cc48 100644
--- a/class_assign_1.f08
+++ b/class_assign_1.f08
@@ -12,7 +12,8 @@ module base_mod
end type base
abstract interface
- module function base_add(l, r) result(res)
+ function base_add(l, r) result(res)
+ import base
class(base), intent(in) :: l
integer, intent(in) :: r
class(base), allocatable :: res
@@ -41,7 +42,7 @@ module extend_mod
end type extend
contains
- module function add(l, r) result(res)
+ function add(l, r) result(res)
class(extend), intent(in) :: l
integer, intent(in) :: r
class(base), allocatable :: res
The code
class_assign_1.f08
makes inappropriate use of the MODULE attribute in several places (there are no submodules involved here). In addition, the abstract interface forbase_add
needs to import the derived typebase
; the interface body is a separate scoping unit and doesn't know anything aboutbase
otherwise (this suggests gfortran has a bug here).With this diff the code compiles and runs cleanly with NAG 6.1 and Intel 18.0.1