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

Bug report: `associated` function of ifort and ifx behave differently

zoziha
Novice
1,296 Views

In the following code, the `associated` function of ifort and ifx does not behave the same. There should be a bug in ifort:

program main
    
    abstract interface
        subroutine foo_fcn()
        end subroutine
    end interface
    
    procedure(foo_fcn), pointer :: fcn_ptr
    fcn_ptr => prt
    
    call fcn_ptr()
    print *, associated(fcn_ptr, prt), associated(fcn_ptr)
    
contains
    
    subroutine prt()
        print *, 'Hello, World!'
    end subroutine
    
end program

The results of ifort and ifx:

>> ifort main.f90 && ./a
 Hello, World!
 F T
>> ifx main.f90 && ./a
 Hello, World!
 T T

 

0 Kudos
6 Replies
Barbara_P_Intel
Employee
1,260 Views

I like these nice short reproducers! Thank you.

Which compiler version are you using? I used ifort 2021.8.0 and got this. 

$ ifort --version
ifort (IFORT) 2021.8.0 20221119
Copyright (C) 1985-2022 Intel Corporation.  All rights reserved.

$ ifort main.f90
$ a.out
 Hello, World!
 T T
$ ifx --version
ifx (IFORT) 2023.0.0 20221201
Copyright (C) 1985-2022 Intel Corporation. All rights reserved.

$ ifx main.f90
$ a.out
 Hello, World!
 T T

 These compilers were released as part of oneAPI HPC Toolkit 2023.0 in December 2022. Download it here.

 

0 Kudos
zoziha
Novice
1,233 Views

Locally, my version is Visual-Studio 2022 + Intel-Fortran 2023.0.0:

zoziha_0-1675416577045.png

 

Similarly, in godbolt, click this link to see the results of the example source file.

zoziha_1-1675416619180.png

 

Interestingly, I compiled the example using the visual-studio release mode, and ifort gave the correct results!

0 Kudos
andrew_4619
Honored Contributor III
1,223 Views

Just to confirm I did a debug build (on windows) with Intel® Fortran Compiler Classic 2021.8.0 [Intel(R) 64] and got the 'bad' result.

 

0 Kudos
Barbara_P_Intel
Employee
1,203 Views

Ah! The devil's in the details! Debug mode!

I get the wrong answers on both Windows and Linux when I compile with -g or -O0. Other optimization levels are just fine.

I filed a bug, CMPLRIL0-35148. I'll let you know when it's fixed.



Barbara_P_Intel
Employee
1,193 Views

In the meantime, use ifx. It works!


0 Kudos
Barbara_P_Intel
Employee
963 Views

We value your input and helping us improve our products. However, the Intel® Fortran Compiler Classic with this issue will not receive a fix. We are concentrating our efforts on our new Intel® Fortran Compiler to make it the best in the industry. For this reason, we will close this issue at this time. We encourage you to try our new oneAPI Compilers. Your feedback and suggestions are important to us. Thank you for your efforts to help us improve our products.

Your reproducer works just fine with ifx. Please use ifx as ifort is now deprecated. Please see this information.

There is an ifort to ifx Porting Guide to help you in this transition.

 

0 Kudos
Reply