This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/82064] New: [OOP] multiple incompatible definitions of extended derived type via module use
- From: "daanvanvugt at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 31 Aug 2017 18:25:02 +0000
- Subject: [Bug fortran/82064] New: [OOP] multiple incompatible definitions of extended derived type via module use
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82064
Bug ID: 82064
Summary: [OOP] multiple incompatible definitions of extended
derived type via module use
Product: gcc
Version: 7.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: daanvanvugt at gmail dot com
Target Milestone: ---
Created attachment 42097
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42097&action=edit
Makefile, base type, extra module and test program
When using an extended derived type from a module through two, different, other
modules they become incompatible.
The interesting part is that I use `private` everywhere so the type itself is
not actually shared.
This results in interesting phenomena such as select type not working as
expected, and errors of class(t1) not matching class(t1).
In the attached zip file are the files needed to reproduce.
Run `make` to create `test_sep` from test_sep.f90 which prints ERR twice on my
machine.
Putting all the modules and the program together in one file yields a program
that prints OK twice. (test.f90)
I have written some changes that cause the problem to disappear as comments.
module mod_types
type, abstract :: t
end type t
type, extends(t) :: t2
end type t2
end module mod_types
module mod_f
use mod_types
implicit none
private
contains
! Remove this function to fix
subroutine f(particle)
! if the classname here matches the type name in test_sep it breaks
class(t2), intent(inout) :: particle
! using type instead of class here also works
end subroutine f
end module mod_f
module mod_test
use mod_types
!use mod_boris ! uncomment for a fix
implicit none
private
public :: init
contains
subroutine init(p)
class(t), intent(inout) :: p
select type (p)
type is (t2)
write(*,*) "OK"
class default
write(*,*) "ERR"
end select
end subroutine init
end module mod_test
program test_sep
use mod_types
use mod_f ! remove this to fix
use mod_test
class(t), allocatable :: p
type(t2) :: p2
allocate(t2::p)
call init(p)
call init(p2)
end program test_sep