Working on a fairly large simulation codebase, and ran across what appears to be a bug related to intrinsic assignment of derived types. I know this area has long been a pain point. This bug is specific to an interaction of a derived type with allocatable component, and a BLOCK construct that doesn’t fire. See below for the reproducer. Its fairly easy to work around it as long as you’re aware of it.
! ifx 2026.2.0 (20261001), Linux x86-64: intrinsic assignment of a derived type with an allocatable
! component gives a destination component that ALLOCATED() reports as allocated but whose address is null,
! when the same procedure contains a BLOCK that is NOT executed and declares a local of a derived type with
! allocatable components (here inner_t, or outer_t itself).
! ifx repro.f90 -o repro && ./repro (same result at -O0, -O2 and with -check bounds,pointers)
! Expected: PASS: dst%in%a = 1 2 3
! Actual: FAIL: dst%in%a reported allocated but has a null address
! (any access to dst%in%a then segfaults)
! It passes when:
! - the BLOCK is executed (call s(.true., x)),
! - the IF around the BLOCK is removed,
! - tmp is declared at procedure scope instead of in the BLOCK,
! - the BLOCK local is of a type without allocatable components,
! - the BLOCK local is an allocatable intrinsic array, or of a type unrelated to outer_t,
! - the assignment copies an inner_t (dst of type inner_t) rather than a type containing one,
! - dst is an INTENT(OUT) dummy instead of a local variable.
module m
implicit none
type :: inner_t
integer, allocatable :: a(:)
end type
type :: outer_t
type(inner_t) :: in
end type
contains
subroutine s(flag, src)
logical, intent(in) :: flag
type(outer_t), intent(in) :: src
type(outer_t) :: dst
if (flag) then
! The issue appears when this block is not executed.
block
type(inner_t) :: tmp
allocate (tmp%a(3), source=7)
print \*, tmp%a
end block
end if
! Intrinsic assignment isn't correct if the block above doesn't run.
dst = src
print '(a,l2,a,i0)', 'allocated(dst%in%a):', allocated(dst%in%a),'loc(dst%in%a): ', loc(dst%in%a)
if (loc(dst%in%a) == 0) then
print '(a)', 'FAIL: dst%in%a reported allocated but has a null address'
else
print '(a,3i3)', 'PASS: dst%in%a =', dst%in%a
end if
end subroutine
end module
program repro
use m
implicit none
type(outer_t) :: x
allocate (x%in%a(3), source=\[1, 2, 3\])
call s(.false., x)
end program