Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29285 Discussions

Bug with constructors, classes, and parameters

Jacob_Williams
New Contributor III
508 Views
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]
0 Kudos
2 Replies
Steven_L_Intel1
Employee
508 Views
You are correct - this is a compiler bug. I will let the developers know. Issue ID is DPD200232954.
0 Kudos
Steven_L_Intel1
Employee
508 Views
This has been fixed for an update later this year (I would guess in the September-October timeframe.)
0 Kudos
Reply