https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121537
Bug ID: 121537
Summary: Missed defined-assignment
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: abensonca at gcc dot gnu.org
Target Milestone: ---
Current gfortran misses a defined-assignment of a component in the following
test case:
module typeMod
type :: type1
integer :: i
contains
procedure :: type1Assigner
generic :: assignment(=) => type1Assigner
end type type1
type :: type2
type(type1) :: t1
end type type2
contains
subroutine type1Assigner(to,from)
implicit none
class(type1), intent( out) :: to
class(type1), intent(in ) :: from
write (*,*) "DO ASSIGNMENT"
to%i=from%i+1
return
end subroutine type1Assigner
end module typeMod
program assign
use typeMod
class(type2), allocatable :: a, b
allocate(type2 :: b)
allocate(a,mold=b)
a=b
end program assign
The assignment `a=b` (both of type `type2`) should trigger the
defined-assignment of the component `t1` (of type `type1`). With the current
gfortran this does not happen - the above *does not* output `DO ASSIGNMENT` in
this case:
> gfortran -v
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/carnegie/nobackup/users/abenson/upstream/libexec/gcc/x86_64-pc-linux-gnu/16.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure
--prefix=/carnegie/nobackup/users/abenson/upstream --disable-multilib
--enable-checking=release --enable-host-shared --with-pic
--enable-languages=c,c++,fortran,jit,lto
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 16.0.0 20250804 (experimental) (GCC)
> gfortran assign.F90
> ./a.out
For reference, `ifort` *does* output `DO ASSIGNMENT`:
> ifort assign.F90
> ./a.out
DO ASSIGNMENT