- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
ifort/2021.7.0 and earlier versions seem to miscompile the following example:
program p
implicit none
type t
integer :: c
end type
type, extends (t) :: t2
integer :: c2
end type
class(t), allocatable :: x, r
integer :: i = 1
x = t2(1,-1)
r = merge (x, x, i == 1)
! r = merge (x, x, .true.)
select type (z => r)
type is (t)
print *,"type is (t) :", z% c
type is (t2)
print *,"type is (t2):", z% c, z% c2
end select
end program p
The resulting code prints:
type is (t) : 1
Note that the NAG compiler 7.1 differs here, it prints:
type is (t2): 1 -1
I would expect the latter as the expected result.
Am I missing something?
Thanks,
Harald
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This problem is reproduced with the latest compiler build and escalated to the development team to be fixed.
Note that gfortran also behaves similar to ifort and ifx.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is a good little test. a few places where the compiler is getting things wrong. Possible the MERGE intrinsic is returning the parent type(t) instead of t2 as it should. Also possible the select type is pulling the parent type t instead of the extended type t2 from r.
We'll get a bug report on this.
Thanks for sending this to us.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This problem is reproduced with the latest compiler build and escalated to the development team to be fixed.
Note that gfortran also behaves similar to ifort and ifx.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There is an open bug report with gfortran with a slightly enhanced version of the above test, see
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105371#c8
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The bug is fixed in latest Intel Fortran compiler versions, e.g. 2023.1
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page