- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm seeing something that I think might be a compiler bug (in 2011 Update 10 of the compiler)...or perhaps I'm doing something non-standard. See code below for a simple example. I'm extending a type, then declaring some variables using the default constructor. The variables from the base type are not getting set properly if the variable is a parameter (it works if it is not a parameter). Does the standard not allow parameters in this context, or is it a bug?
[fortran]!********************************************************************************** module test !********************************************************************************** implicit none private !base class: type,public :: base_class integer :: id = 0 integer :: order = 0 end type base_class !extend it: type,extends(base_class),public :: extended_class integer :: blah = 0 end type extended_class !define some variables: type(extended_class),parameter,public :: a = extended_class(999, 9, 1) type(extended_class),parameter,public :: b = extended_class(888, 8, 2) type(extended_class),parameter,public :: c = extended_class(777, 7, 3) type(extended_class),public :: aa = extended_class(999, 9, 1) type(extended_class),public :: bb = extended_class(888, 8, 2) type(extended_class),public :: cc = extended_class(777, 7, 3) public :: test_routine contains !********************************************************************************** !************************************************************** subroutine test_routine() !************************************************************** implicit none write(*,*) 'a', a%id,a%order,a%blah !should be 999,9,1 -> instead writes: 1,1,1 write(*,*) 'b', b%id,b%order,b%blah !should be 888,8,2 -> instead writes: 1,1,2 write(*,*) 'c', c%id,c%order,c%blah !should be 777,7,3 -> instead writes: 1,1,3 write(*,*) 'aa', aa%id,aa%order,aa%blah !these work write(*,*) 'bb', bb%id,bb%order,bb%blah ! write(*,*) 'cc', cc%id,cc%order,cc%blah ! !************************************************************** end subroutine test_routine !************************************************************** !********************************************************************************** end module test !********************************************************************************** !********************************************************************************** program main !********************************************************************************** use test implicit none call test_routine() !********************************************************************************** end program main !**********************************************************************************[/fortran]
[fortran]!********************************************************************************** module test !********************************************************************************** implicit none private !base class: type,public :: base_class integer :: id = 0 integer :: order = 0 end type base_class !extend it: type,extends(base_class),public :: extended_class integer :: blah = 0 end type extended_class !define some variables: type(extended_class),parameter,public :: a = extended_class(999, 9, 1) type(extended_class),parameter,public :: b = extended_class(888, 8, 2) type(extended_class),parameter,public :: c = extended_class(777, 7, 3) type(extended_class),public :: aa = extended_class(999, 9, 1) type(extended_class),public :: bb = extended_class(888, 8, 2) type(extended_class),public :: cc = extended_class(777, 7, 3) public :: test_routine contains !********************************************************************************** !************************************************************** subroutine test_routine() !************************************************************** implicit none write(*,*) 'a', a%id,a%order,a%blah !should be 999,9,1 -> instead writes: 1,1,1 write(*,*) 'b', b%id,b%order,b%blah !should be 888,8,2 -> instead writes: 1,1,2 write(*,*) 'c', c%id,c%order,c%blah !should be 777,7,3 -> instead writes: 1,1,3 write(*,*) 'aa', aa%id,aa%order,aa%blah !these work write(*,*) 'bb', bb%id,bb%order,bb%blah ! write(*,*) 'cc', cc%id,cc%order,cc%blah ! !************************************************************** end subroutine test_routine !************************************************************** !********************************************************************************** end module test !********************************************************************************** !********************************************************************************** program main !********************************************************************************** use test implicit none call test_routine() !********************************************************************************** end program main !**********************************************************************************[/fortran]
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You are correct - this is a compiler bug. I will let the developers know. Issue ID is DPD200232954.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This has been fixed for an update later this year (I would guess in the September-October timeframe.)

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