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

ICE: Function `associated` bug for Intel Fortran compiler (ifort)?

zoziha
Novice
434 Views

Same as: Function `associated` bug for Intel Fortran compiler? - Help - Fortran Discourse (fortran-lang.discourse.group)

The following code will cause ICE (Internal compiler error) to occur in `ifort`:

 

module test_m

    implicit none
    private

    public :: f, set_method

    ! local procedure pointer
    procedure(func), pointer :: f

    abstract interface
        function func(x)
            character(*), intent(in) :: x
            character(:), allocatable :: func
        end function func
    end interface

contains

    ! set method
    subroutine set_method(ifunc)
        integer, intent(in) :: ifunc
        if (ifunc == 1) then
            if (.not. associated(f, starts)) f => starts ! This line 
        elseif (ifunc == 2) then
            !...
        end if
    end subroutine set_method

    function starts(x)
        character(*), intent(in) :: x
        character(:), allocatable :: starts
        starts = ">"//x
    end function starts

end module test_m

program main

    use test_m
    implicit none

    call set_method(1)
    print *, f("string")

end program main

 

I suspect it is related to `associated` function, remove the `associated` judgment code to compile and pass:

 

    ! set method
    subroutine set_method(ifunc)
        integer, intent(in) :: ifunc
        if (ifunc == 1) then
            f => starts   ! Note here 

 

0 Kudos
3 Replies
Ron_Green
Moderator
381 Views

definitely a bug.  I'll get a bug report started and will update this post and the fortran-discourse with same.

 

Thanks for bringing this to our attention.

0 Kudos
Barbara_P_Intel
Moderator
348 Views

I filed a bug report for this, CMPLRIL0-34800. Will post when a fix is available.



Barbara_P_Intel
Moderator
222 Views

The ICE when using ASSOCIATED() is fixed in the current release of the compiler. It was made available in December and is part of oneAPI HPC Toolkit 2023.0.

Try it out!



0 Kudos
Reply