- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The following example produces what I believe is a spurious runtime error. It runs correctly using gfortran. The example involves defined assignment of polymorphic variables and assignment of unlimited polymorphic components.
module foo_class
type, abstract :: foo
contains
procedure, private :: foo_copy
generic :: assignment(=) => foo_copy
procedure(foo_copy), deferred :: foo_copy_
end type
type, extends(foo) :: foo_bar
class(*), allocatable :: value
contains
procedure :: foo_copy_ => foo_bar_copy
end type
contains
subroutine foo_copy(lhs, rhs)
class(foo), intent(inout) :: lhs
class(foo), intent(in) :: rhs
if (same_type_as(lhs, rhs)) then
call lhs%foo_copy_(rhs)
else
error stop
end if
end subroutine
subroutine foo_bar_copy(lhs, rhs)
class(foo_bar), intent(inout) :: lhs
class(foo), intent(in) :: rhs
select type (rhs)
type is (foo_bar)
print *, 'before foo_bar assignment'
lhs%value = rhs%value ! RUNTIME ERROR HERE
print *, 'after foo_bar assignment'
end select
end subroutine
end module
use foo_class
class(foo), allocatable :: src, dest
!! Define SRC
allocate(foo_bar::src)
select type (src)
type is (foo_bar)
allocate(src%value, source=1)
end select
!! Copy SRC to DEST
allocate(dest, mold=src)
print *, 'before foo assignment'
dest = src
print *, 'after foo assignment'
end
The expected results are:
before foo assignment
before foo_bar assignment
after foo_bar assignment
after foo assignment
With ifx I get:
$ ifx -traceback intel-20231205.f90
$ ./a.out
before foo assignment
before foo_bar assignment
forrtl: severe (122): invalid attempt to assign into a pointer that is not associated
Image PC Routine Line Source
a.out 0000000000408E7F Unknown Unknown Unknown
a.out 0000000000405327 foo_bar_copy 34 foo.f90
a.out 0000000000405679 _unnamed_main$$ 54 foo.f90
a.out 000000000040519D Unknown Unknown Unknown
libc.so.6 00007F2DA5D6A550 Unknown Unknown Unknown
libc.so.6 00007F2DA5D6A609 __libc_start_main Unknown Unknown
a.out 00000000004050B5 Unknown Unknown Unknown
The error message involves a pointer but there is not a pointer anywhere in this example.
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I agree. It's a compiler bug.
The good news is that it is fixed in the next minor release of ifx and ifort. It's planned to be released near the end of Q1 2024.
ifx -what -traceback nc.f90
Intel(R) Fortran 24.0-1444
a.out
before foo assignment
before foo_bar assignment
after foo_bar assignment
after foo assignment
rm a.out
ifort -what -traceback nc.f90
ifort: remark #10448: Intel(R) Fortran Compiler Classic (ifort) is now deprecated and will be discontinued late 2024. Intel recommends that customers transition now to using the LLVM-based Intel(R) Fortran Compiler (ifx) for continued Windows* and Linux* support, new language support, new language features, and optimizations. Use '-diag-disable=10448' to disable this message.
Intel(R) Fortran 2021.12.0-1425
a.out
before foo assignment
before foo_bar assignment
after foo_bar assignment
after foo assignment
- 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
I just confirmed that the runtime error you reported is indeed fixed in ifx 2024.1.0. That version was released last week. Give it a try!

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