- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
the following example shows that PACK() of CLASS entities may lose the dynamic type:
program p
implicit none
type t
integer :: i
end type t
type, extends(t) :: t2
real :: x = 3.
end type t2
class(t), allocatable :: x(:), y(:)
allocate (t2 :: x(3))
x% i = [1,2,3]
print *, x% i
! y = x ! OK
print *, "Testing merge:"
y = merge (x, x, .true.) ! OK
print *, y% i
call check ()
print *, "Testing pack:"
y = pack (x, .true.) ! not OK
print *, y% i
call check ()
contains
subroutine check ()
print *, "same_type_as (x,y) =", same_type_as (x,y)
select type (x)
type is (t2)
print *, "x is t2"
class default
print *, "x is not OK"
end select
select type (y)
type is (t2)
print *, "y is t2 (OK)"
class default
print *, "y is not OK"
end select
end subroutine check
end
NAG produces the expected result:
1 2 3
Testing merge:
1 2 3
same_type_as (x,y) = T
x is t2
y is t2 (OK)
Testing pack:
1 2 3
same_type_as (x,y) = T
x is t2
y is t2 (OK)
Intel 24.0-1693.2 howver gives:
1 2 3
Testing merge:
1 2 3
same_type_as (x,y) = T
x is t2
y is t2 (OK)
Testing pack:
1 2 3
same_type_as (x,y) = F
x is t2
y is not OK
So while MERGE() has been fixed in the meantime, intrinsic PACK() was obviously missed.
Thanks,
Harald
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @Harald1
good news, we implemented a fix for this issue. It will be part of the next release, 2025.1
Best
Tobias

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