Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Valued Contributor III
12 Views

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

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
Highlighted
Valued Contributor III
12 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. 

0 Kudos