Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29253 Discussions

Structure constructors for extended types

IanH
Honored Contributor III
480 Views

I think structure constructors that include a parent component can confuse the current release of the compiler.

[fortran]MODULE m20130816
  IMPLICIT NONE
  TYPE :: Parent
    LOGICAL :: l
    INTEGER, ALLOCATABLE :: array(:)
  END TYPE Parent
  TYPE, EXTENDS(Parent) :: Extension
    REAL :: b
    REAL :: c
  END TYPE Extension
END MODULE m20130816

PROGRAM ExtensionStructureConstructor
  USE m20130816
  IMPLICIT NONE
  TYPE(Parent) :: p_scalar
  TYPE(Parent) :: p_array(2)
  TYPE(Extension) :: e
  !****
  p_scalar = Parent(.FALSE., [1, 2, 3])
  ! This one is ok.
  e = Extension(PARENT=p_scalar, B=2.0, C=3.0)
 
  p_array(1) = Parent(.FALSE., [1, 2, 3])
  ! This one gives error #8212.
  e = Extension(PARENT=p_array(1), B=2.0, C=3.0)
END PROGRAM ExtensionStructureConstructor
[/fortran]

[plain]>ifort /c /check:all /warn:all /standard-semantics ExtensionStructureConstructor.f90
Intel(R) Visual Fortran Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 13.1.3.198 Build 20130607
Copyright (C) 1985-2013 Intel Corporation.  All rights reserved.

ExtensionStructureConstructor.f90(26): error #8212: Omitted field is not initialized. Field initialization missing:  
  e = Extension(PARENT=p_array(1), B=2.0, C=3.0)
^
compilation aborted for ExtensionStructureConstructor.f90 (code 1)[/plain]

I think the error message is exhorting me to break F2008 C491.  But me mum told me not to do that, or I'd get into big trouble.

0 Kudos
3 Replies
Steven_L_Intel1
Employee
480 Views

I know we've had problems like this in the past, but I still see the error here in our latest compiler. Let me look at it in more detail.

0 Kudos
Steven_L_Intel1
Employee
480 Views

Ian, thanks for the nice example. Escalated as issue DPD200247227.

0 Kudos
Steven_L_Intel1
Employee
480 Views

This bug has been fixed - I expect the fix to appear in the October update.

0 Kudos
Reply