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

Support for F2003 allocatable components and structure constructors

IanH
Honored Contributor II
353 Views

In case this is an oversight, Fortran 2003's ability to use an unallocated entity for the component specification that corresponds to an allocatable component in a structure constructor does not appear to have been implemented in current compilers.  If only I had of known this yesterday!

MODULE m
  PRIVATE
  TYPE, PUBLIC :: t
    INTEGER, ALLOCATABLE :: comp
  END TYPE t
END MODULE m

PROGRAM p
  USE m
  IMPLICIT NONE
  TYPE(t) :: x, y, z
  INTEGER, ALLOCATABLE :: not_allocated
  
  x = t(NULL())           ! ok.
  y = t(1)                ! ok.
  z = t(not_allocated)    ! explodes.
  
  PRINT *, ALLOCATED(x%comp), ALLOCATED(y%comp), ALLOCATED(z%comp)
END PROGRAM p

F2003 4.5.9 para 6 or so - "If a component of a derived type is allocatable, the corresponding constructor expression shall either be ... an allocatable entity of the same rank  ...  If the expression is an allocatable entity, the corresponding component of the constructor has the same allocation status as that allocatable entity and, if it is allocated, the same dynamic type, bounds and value."

This missing feature has thwarted my evil plans to submit an ICE that occurs with some of the most horrible (but still F2003 conforming, bar 1.4(5)) source that your compiler support people will have ever seen.  I am sure you are all very disappointed.

(Oops - forgot this bit...

>ifort /check:all /warn:all /standard-semantics /traceback "2016-06-05 allocatable-component.f90" && "2016-06-05 allocatable-component.exe"
Intel(R) Visual Fortran Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 16.0.3.207 Build 20160415
Copyright (C) 1985-2016 Intel Corporation.  All rights reserved.

Microsoft (R) Incremental Linker Version 14.00.23918.0
Copyright (C) Microsoft Corporation.  All rights reserved.

"-out:2016-06-05 allocatable-component.exe"
-subsystem:console
-incremental:no
"2016-06-05 allocatable-component.obj"
forrtl: severe (157): Program Exception - access violation
Image              PC                Routine            Line        Source
2016-06-05 alloca  000000013F071238  MAIN__                     16  2016-06-05 allocatable-component.f90
2016-06-05 alloca  000000013F0BD28E  Unknown               Unknown  Unknown
2016-06-05 alloca  000000013F0BDB80  Unknown               Unknown  Unknown
kernel32.dll       00000000776759BD  Unknown               Unknown  Unknown
ntdll.dll          00000000778AA2E1  Unknown               Unknown  Unknown

)

0 Kudos
3 Replies
jimdempseyatthecove
Honored Contributor III
353 Views

>>... thwarted my evil plans

So you missed it by "this much"? (Maxwell Smart)

IanH you are one of this, if not the, forum's most prolific bug catcher. Thank you for all your efforts.

Jim Dempsey

0 Kudos
Steven_L_Intel1
Employee
353 Views

Thanks - escalated as issue DPD200411531. I think this was an oversight.

0 Kudos
JohnNichols
Valued Contributor III
353 Views

In case this is an oversight, Fortran 2003's ability to use an unallocated entity for the component specification that corresponds to an allocatable component in a structure constructor does not appear to have been implemented in current compilers.

I want to get this printed on a T-Shirt and on the back say:

IF THIS MAKES SENSE TO YOU MIT WANTS YOU!

0 Kudos
Reply