- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Compiler: ifx (IFX) 2025.2.0
OS: Rocky Linux 8.10 (Green Obsidian)
I've found a bug at the intersection of parameterized derived types and defined assignment, specifically when nested 3 classes deep. In the following code, the print statement should display, but it does not.
module Classes_Header
implicit none
type :: class1
integer :: ii
contains
generic, public :: assignment(=) => copy
procedure, private :: copy
end type
type :: class2
type(class1) :: myClass1
end type
type :: class3(n)
integer, len :: n
type(class2) :: myClass2
end type
contains
subroutine copy(lhs,rhs)
class(class1), intent(out) :: lhs
class(class1), intent(in) :: rhs
lhs%ii = 7
print *, 'copy was called - worked as expected'
end subroutine
function constructor() result(this)
type(class3(4)) :: this
this%myClass2%myClass1%ii = 42
end function
end module
program main
use Classes_Header
implicit none
type(class3(:)), allocatable :: myClass3
myClass3 = constructor()
end program
Note that if class3 is not a parameterized derived type, the defined assignment is called as expected. This is true even if class3 remains an allocatable in the program main.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Note the similarities and differences between this and another issue I just updated. In both bugs, the defined assignment is not called. Here, the problem comes from the parameterized derived type, while the other issue is a nested class structure containing an `allocatable` class.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for sending this to us. The bug ID is CMPLRLLVM-68773
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Three other cases to add here. They are subtle differences from my original post, but I wanted to make sure these edge cases were caught. In short, the defined assignment is neither called when class3 is a class-allocatable nor when it extends from an abstract class nor when it's a type with the same parameter; see the attached files for specifics. I appended "TypeAllocatable_OriginalPost" onto the name of the file above for clarity, but it is the same otherwise.
@Ron_Green, should I make separate issues for these bugs or leave them as part of this one?

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page