Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
New Contributor I
13 Views

Wrong result depending on order of component in DT

Hi,

The following code creates wrong outputs.

! Compilation & excecution:    ifort main.f90 ; ./a.out
Module Universal_Class
  implicit none
  Type  ,abstract                 ::      Universal_Type
  End Type
End Module

Module Structure_Class
  use Universal_Class   ,only:  Universal_Type
  implicit none
  Type  ,extends(Universal_Type)  ::      Structure_Type
    character(6)                  ::      Name  =   "Empty "
    integer   ,dimension(1)       ::      ivar  =   [0]
  End Type
End Module

Program Main
  use Structure_Class   ,only:  Structure_Type
  implicit none
  type(Structure_Type) ,parameter ::  Svar    =   Structure_Type( Name="Filled",ivar=[1] )
  write(*,"('              ',a15,3x,a15)") 'Found', 'Expected'
  write(*,"('              ',a15,3x,a15)") '-----', '-----'
  write(*,"('  Svar%Name = ',a15,3x,a15)") Svar%Name, 'Filled'
  write(*,"('  Svar%ivar = ',i15,3x,i15)") Svar%ivar, 1
End Program

The outputs are:

                      Found          Expected
                      -----             -----
Svar%Name =          Filled            Filled
Svar%ivar =             256                 1

The correct outputs are obtained if either one of the following modifications is done

  • the order of the components inside the "Structure_Type" derived-type are changed
  • the inheritance is removed

I'v only tested the code with ifort version 15.0.6.

Thanks for investigating.

 

0 Kudos
2 Replies
Highlighted
13 Views

Thanks, this is still reproducible in 16.0.2. I find that the problem also goes away if Svar is a variable and not a PARAMETER. Escalated as issue DPD200382227.

0 Kudos
Highlighted
13 Views

I expect this problem to be fixed in the 17.0 compiler release.

0 Kudos