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

Automatic allocation of allocatable scalars with allocatable components

IanH
Honored Contributor III
674 Views

Is this supported?  Some tests here with 13.1.0 indicate "sort of".

[fortran]PROGRAM AllocatableScalars
  IMPLICIT NONE
 
  TYPE :: TypeOne
    INTEGER :: int1
  END TYPE TypeOne
 
  TYPE :: TypeTwo
    INTEGER :: int2
    CHARACTER(:), ALLOCATABLE :: str2
  END TYPE TypeTwo
 
  TYPE(TypeOne), ALLOCATABLE :: lhs1
  TYPE(TypeOne) :: rhs1
 
  TYPE(TypeTwo), ALLOCATABLE :: lhs2
  TYPE(TypeTwo) :: rhs2
 
  !****
 
  rhs1%int1 = 1
  lhs1 = rhs1               ! Ok.
  PRINT *, lhs1%int1
 
  rhs2%int2 = 2
  rhs2%str2 = 'Two'
  lhs2 = rhs2               ! Explodes.
  PRINT *, lhs2%int2, lhs2%str2
END PROGRAM AllocatableScalars[/fortran]

[plain]>ifort /check:all /warn:all /standard-semantics /traceback "2013-03-04 AllocatableScalars.f90" && "2013-03-04 AllocatableScalars.exe"
Intel(R) Visual Fortran Compiler XE for applications running on IA-32, Version 13.1.0.149 Build 20130118
Copyright (C) 1985-2013 Intel Corporation.  All rights reserved.

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

"-out:2013-03-04 AllocatableScalars.exe"
-subsystem:console
-incremental:no
"2013-03-04 AllocatableScalars.obj"
 1
forrtl: severe (408): fort: (7): Attempt to use pointer LHS2 when it is not associated with a target

Image              PC        Routine            Line        Source
2013-03-04 Alloca  00C18830  Unknown               Unknown  Unknown
2013-03-04 Alloca  00BE2736  Unknown               Unknown  Unknown
2013-03-04 Alloca  00BD4CF2  Unknown               Unknown  Unknown
2013-03-04 Alloca  00BD5463  Unknown               Unknown  Unknown
2013-03-04 Alloca  00BD1244  _MAIN__                    27  2013-03-04 AllocatableScalars.f90
2013-03-04 Alloca  00C197E3  Unknown               Unknown  Unknown
2013-03-04 Alloca  00C04B24  Unknown               Unknown  Unknown
kernel32.dll       76F2D2E9  Unknown               Unknown  Unknown
ntdll.dll          771C1603  Unknown               Unknown  Unknown
ntdll.dll          771C15D6  Unknown               Unknown  Unknown[/plain]

This feels a little familiar - so apologies if it is a repeat report.

0 Kudos
3 Replies
jimdempseyatthecove
Honored Contributor III
674 Views

>>forrtl: severe (408): fort: (7): Attempt to use pointer LHS2 when it is not associated with a target

It would seem like the compiler thinks the assignment is constructing a pointer to the allocatable character.

Try: CHARACTER(:), ALLOCATABLE, TARGET :: str2
...
PRINT *, lhs2%int2, lhs2%str2, LOC(rhs2%str2), LOC(lhs2%str2)
See if the result was COPY of or make POINTER to.

If the above is copy of, then adding TARGET may be a work around to use until a fix is made.

Jim Dempsey

0 Kudos
Steven_L_Intel1
Employee
674 Views

The assignment itself is working, but /check:pointer is confused. If you remove /check:pointer it will run ok. I will let the developers know.  The issue ID is DPD200241669.

0 Kudos
Steven_L_Intel1
Employee
674 Views

The /check:pointer interaction has been fixed for a release later this year.

0 Kudos
Reply