- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
[sectionBody]Hello all, I'm having some strange behavior using the private / public attributes in my modules. The code below compiles if I uncomment the line that says "public :: base_par_type", but this line refers to a type defined in a different module. If I leave the line commented out I get the error message below. This shouldn't happen as I should not even be able to declare base_par_type as public in the module my_par_class right? Im using ifort (IFORT) 11.1 20091012. thanks.
private_test.F90(45): error #6633: The type of the actual argument differs from the type of the dummy argument. [MYPAR]
call grid%add(mypar)
!-----------------------------
module base_par_class
private
public :: base_par_type
type base_par_type
real :: p
end type base_par_type
end module base_par_class
!-----------------------------
module my_par_class
use base_par_class
private
public :: my_par_type
!public :: base_par_type
type, extends(base_par_type) :: my_par_type
real :: m
end type my_par_type
end module my_par_class
!-----------------------------
module grid_class
use base_par_class
private
public :: grid_type
type grid_type
real :: data
contains
procedure, pass :: add
end type grid_type
contains
subroutine add(this, par)
class(grid_type) :: this
class(base_par_type) :: par
end subroutine add
end module grid_class
!-----------------------------
program test
use my_par_class
use grid_class
type(my_par_type) :: mypar
type(grid_type) :: grid
call grid%add(mypar)
end program test
[/sectionBody]
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
1. There is nothing illegal about making base_par_type public in my_par_class. Doing so means that a scoping unit that uses my_par_class (e.g., your main program) would be allowed to use the name base_par_type (e.g., to declare another object) without explicitly using base_par_class.
2. On the other hand, I see no reason why you should be required to make base_par_type public in my_par_class. Unless I've missed something, the error message is a bug. Because the dummy argument par in add is declared class(base_par_type), an exact type match should not be required, and you should not need the ability to declare objects of type base_par_type in order for the compiler to recognize that an object of type my_par_type should match class(base_par_type).
-Kurt
2. On the other hand, I see no reason why you should be required to make base_par_type public in my_par_class. Unless I've missed something, the error message is a bug. Because the dummy argument par in add is declared class(base_par_type), an exact type match should not be required, and you should not need the ability to declare objects of type base_par_type in order for the compiler to recognize that an object of type my_par_type should match class(base_par_type).
-Kurt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I agree that this is a compiler bug. I have escalated it as issue DPD200148744.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Steve Lionel (Intel)
I agree that this is a compiler bug. I have escalated it as issue DPD200148744.
thanks Kurt and Steve.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It turns out that this was a bug previously reported and already fixed in our sources. I expect the fix to appear in Update 5 (late January). The issue ID is DPD200140688.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page