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

IFX 2023.0.0 runtime error on Windows - allocatable array or pointer is not allocated

fortrandave
New Contributor I
947 Views

Greetings,

Please consider the following code which generates a runtime error in IFX 2023.0.0 but not in Classic.  Can this be fixed for the next point release?

! Compiles and runs with with Classic:
! Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on
! Intel(R) 64, Version 2021.8.0 Build 20221119_000000
!
! Compiles but generates run time errors with IFX:
! Intel(R) Fortran Compiler for applications running on Intel(R) 64, Version
! 2023.0.0 Build 20221201
! forrtl: severe (153): allocatable array or pointer is not allocated
!***********************************************************************
    module mymod_m
    implicit none

    type mytype
        character(:), allocatable :: links
    end type mytype

    type(mytype), target :: sd

    contains
!*******************************************************************************
    subroutine update(fdir)
    character(len=*), intent(in) :: fdir

    print *, "fdir in update: "//trim(fdir)
    sd%links = fdir

    end subroutine update
!*******************************************************************************
    function fixdir() result(fdir)
    character(:), allocatable :: fdir

    fdir = 'stuff'
    call update(fdir)
    print *, "fdir in fixdir: ", fdir

    end function fixdir

    end module mymod_m
!*******************************************************************************
    program allocate_error
    use mymod_m
    implicit none

    sd%links = fixdir()

    end program allocate_error

Thanks,
Dave

10 Replies
JohnNichols
Valued Contributor III
925 Views

it runs and you get the correct answer in ifx, but for some strange reason it throws the error on exiting line 44 it appears.  Watch shows the correct value on entry. 

0 Kudos
andrew_4619
Honored Contributor II
923 Views

It certainly would not win prizes for good coding practice but I would be interested in some comment of the legality. I would expect the fixdir function on the RHS to fully complete before sd%links updates on the LHS but fixdir changes sd%links during it execution so sd%links gets updated twice.....

0 Kudos
Barbara_P_Intel
Moderator
878 Views

It's good to see so many people using ifx! Thanks for reporting this issue.

It fails on Linux at line 44, too.

I filed a bug, CMPLRLLVM-45010. I'll let you know about the fix.

 

 

0 Kudos
fortrandave
New Contributor I
778 Views

You're welcome!  Thanks for accepting this as a bug.  I'm planning on looking at ifx releases as they come out.  There's been some great progress in the last year.

 

I'll follow this thread and watch for a resolution.

0 Kudos
Barbara_P_Intel
Moderator
804 Views

I checked with the resident Intel Fortran standards expert. He says it is legal Fortran.



0 Kudos
fortrandave
New Contributor I
778 Views

Thanks for checking on this.  I thought it was legal, though I agree with @andrew_4619 that it's not the best coding practice.

0 Kudos
Barbara_P_Intel
Moderator
519 Views

@fortrandave, the runtime error is gone with ifx 2024.0.0 that was released this week. Another one fixed for you!



fortrandave
New Contributor I
495 Views

Thanks again!  I'll verify on my side once I get my hands on 2024.0.  Corporate environments take a bit longer to process things.

0 Kudos
JohnNichols
Valued Contributor III
490 Views

who-invented-the-chariot-min-778808840.jpg

Corporates latest idea for transport, the emissions plots are spectacular, the company will be fully green.  

 

0 Kudos
fortrandave
New Contributor I
474 Views

No kidding.  Thanks for a good laugh!  I'm hoping to have it in hand not too long after our Thanksgiving break.

0 Kudos
Reply