Showing results for 
Search instead for 
Did you mean: 
Valued Contributor III
1 View

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"


   subroutine alloc( bar )

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

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

   end subroutine


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 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.


 foo%ell =  1 ; expected = 42

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

0 Kudos
1 Reply
Valued Contributor III
1 View

I should point out in the

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