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

Slight change in behaviour of allocated intrinsic function in IFX

Andrew_Smith
Valued Contributor I
376 Views

If a derived type a has an allocatable component b, and b also has an allocatable component c, then allocated(a%b%c) with IFORT returns .TRUE. if either b or c is not allocated. In IFX, it fails if b is not allocated. I suspect its closer to the standard now. But now I have to check each in turn and because Fortran does not shortcut the logical expressions once one fails, we have to now use separate if statements to replicate the old behaviour.

if (allocated(a%b)) then

   if (allocated(a%b%c)) then

      ...

0 Kudos
3 Replies
Devorah_H_Intel
Moderator
333 Views

Can you please provide a test case for what you are observing? Our internal testing doesn't confirm the behavior you are describing. 

0 Kudos
Andrew_Smith
Valued Contributor I
299 Views

Hm, you are correct, it fails for both compilers with my reproducer. My actual code had been working. Can you try an older compiler? Here is the reproducer:

module mod1
    implicit none

    type c
      integer dummy
    end type

    type b
      type(c), allocatable :: y
    end type

    type a
      type(b), allocatable :: x
    end type

end module

program test
   use mod1
   implicit none
   type(a) v
   print *, allocated(v%x%y)
   pause
end

 

Devorah_H_Intel
Moderator
274 Views

Thank you, @Andrew_Smith 

0 Kudos
Reply