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

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

fortrandave
Nouveau contributeur I
3 957 Visites

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 Réponses
JohnNichols
Contributeur émérite I
3 935 Visites

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 Compliments
andrew_4619
Contributeur émérite III
3 933 Visites

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 Compliments
Barbara_P_Intel
Employé
3 888 Visites

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 Compliments
fortrandave
Nouveau contributeur I
3 788 Visites

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 Compliments
Barbara_P_Intel
Employé
3 814 Visites

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



0 Compliments
fortrandave
Nouveau contributeur I
3 788 Visites

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 Compliments
Barbara_P_Intel
Employé
3 529 Visites

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



fortrandave
Nouveau contributeur I
3 505 Visites

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 Compliments
JohnNichols
Contributeur émérite I
3 500 Visites

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

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

 

0 Compliments
fortrandave
Nouveau contributeur I
3 484 Visites

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

0 Compliments
Répondre