https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88043
--- Comment #1 from Neil Carlson <neil.n.carlson at gmail dot com> ---
I've been poking at Zach's example and trimmed it down a bit:
In one file:
module typeA
implicit none
private
type, abstract, public :: A
contains
procedure :: call_sub
procedure(z), deferred :: sub
end type
abstract interface
subroutine z(this)
import A
class(A) :: this
end subroutine
end interface
contains
subroutine call_sub(this)
class(A) :: this
print *, 'CALL_SUB'
call this%sub
end subroutine
end module
module typeB
use typeA
implicit none
private
type, extends(A), public :: B
contains
procedure, non_overridable :: sub
procedure :: foo
end type
contains
subroutine sub(this)
class(B) :: this
print *, 'IN SUB'
end subroutine
subroutine foo(this)
class(B) :: this
print *, 'IN FOO!'
end subroutine
end module
And in a separate file:
use typeB
type, extends(B) :: C
end type
type(C) :: x
call x%call_sub
end
The expected output is
CALL SUB
IN SUB
But instead we get
CALL SUB
IN FOO!
Remove the PRIVATE statement from typeA module and we get CALL_SUB calling
itself instead of SUB!