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

IFORT and IFX Compiler Bug

Horne__Steven
Novice
487 Views

The following code produces unexpected output for type2%intValue. This seems to be the simplest form of the code that produces the issue (the type requires an allocatable class field, and the issue requires an assignment to an "intent(out)" variable). I've tested this in IFX 2024.0.2, 2024.2.1, and 2025.0.0, as well as IFORT 2021.11.0 and 2021.12.0. Code posted below and is included in the attached file. gfortran produces the expected output.

module testMod
    type DummyType
    end type DummyType
    
    type ParentType
        class(DummyType), allocatable :: templateObject
        integer :: intValue = 0
    end type ParentType

contains

    subroutine RunTest(type1)
        type(ParentType), intent(out) :: type1
        type(ParentType) :: type2
    
        type1%intValue = 1
        type2 = type1
    
        print *, 'Type1 intValue=',type1%intValue
        print *, 'Type2 intValue=',type2%intValue
    end subroutine RunTest
    
end module testMod

program TestDerivedTypeAssignment
    use testMod, only : ParentType, RunTest

    type(ParentType) :: type1
    
    call RunTest(type1)
end program TestDerivedTypeAssignment

Horne__Steven_0-1730477521960.png

 

Labels (2)
3 Replies
Horne__Steven
Novice
462 Views

Note: this also occurs when a variable is assigned to the result of a function (e.g. with a constructor).

0 Kudos
Devorah_H_Intel
Moderator
196 Views

Thank you for your report. I was able to reproduce the incorrect value. I have escalated this issue to compiler engineering.

0 Kudos
Devorah_H_Intel
Moderator
114 Views

The fix will be available in the 2025.1 ifx release.

0 Kudos
Reply