- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I observe a wrong result with ifx when using EXTENDS_TYPE_OF on elements of a polymorphic allocatable array inside an array constructor. The issue appears with optimization enabled, at least with -O2.
Minimal reproducer:
program bug_report
implicit none
type :: base_type
end type base_type
class(base_type), allocatable :: polymorphic_array(:)
type(base_type) :: element
logical :: test(2)
allocate(polymorphic_array(2))
test = [ &
extends_type_of(polymorphic_array(1), element), &
extends_type_of(polymorphic_array(2), element) &
]
print *, "scalar 1:", extends_type_of(polymorphic_array(1), element)
print *, "scalar 2:", extends_type_of(polymorphic_array(2), element)
print *, "array: ", test
if (.not. all(test)) error stop "wrong result"
end program bug_reportExpected output:
scalar 1: T
scalar 2: T
array: T TActual output with ifx -O2:
scalar 1: T
scalar 2: T
array: F T
ERROR STOP wrong resultThe two scalar calls to EXTENDS_TYPE_OF return the expected value, but the same expressions evaluated inside the array constructor assigned to test produce an incorrect first element.
Compilation commands used:
ifx -O1 bug_report.f90 && ./a.out
ifx -O2 bug_report.f90 && ./a.out
gfortran -O1 bug_report.f90 && ./a.out
gfortran -O2 bug_report.f90 && ./a.outObserved behavior:
ifx -O1: correct result
ifx -O2: wrong result, first element of test is F
gfortran -O1: correct result
gfortran -O2: correct resultCompiler version:
ifx (IFX) 2025.0.4 20241205
System information:
OS: Arch Linux
Link Copied
0 Replies
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page