Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!
26745 Discussions

Incorrect length for an object with a length-type parameter allocated with assumed-size type spec in an ALLOCATE statement

FortranFan
Honored Contributor II
81 Views

Fyi, an incident has been submitted at the Intel Online Service Center (OSC) for the following:

   type t(ell)
      integer, len :: ell
   end type

   type(t(ell=42)), allocatable :: foo

   call alloc( foo )

   print *, "foo%ell = ", foo%ell, "; expected = 42"

contains

   subroutine alloc( bar )

      type(t(ell=*)), allocatable :: bar

      allocate( t(ell=*) :: bar )

   end subroutine

end

Building and execution with Intel Fortran:

xxx>ifort /standard-semantics /warn:all /stand p.f90 -o p.exe
Intel(R) Visual Fortran Intel(R) 64 Compiler for applications running on Intel(R
) 64, Version 18.0.0.124 Build 20170811
Copyright (C) 1985-2017 Intel Corporation.  All rights reserved.

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

-out:p.exe
-subsystem:console
p.obj

xxx>p.exe
 foo%ell =  1 ; expected = 42

Note the length-type parameter is output in error as 1 instead of 42.

0 Kudos
1 Reply
FortranFan
Honored Contributor II
81 Views

I should point out in the small reproducer case, one gets the same erroneous result whether type-spec is included or not in the ALLOCATE statement.  The larger problem being attempted required a type-spec and had run into issues that' prompted the investigation. 

Reply