I ran into a peculiarity with a literal constant (structure constructor) for a derived type. I checked the program below with gfortran and Intel Fortran oneAPI and both are happy to build it:
program chk_type_define
implicit none
type :: params
real :: x
real :: y
end type params
type(params) :: p
p = params( 1, 2.0 )
! Also accepted:
p = params( 10d0, 2 )
! Also accepted:
p = params( (-1.0,3.0), 2 )
write(*,*) p
end program chk_type_define
My question is: is this really allowed or is this an oversight in both compilers? Since Fortran is usually quite strict when it comes to types and kinds, I would expect the compilers to protest against this mixture. Of course, this literal only looks like a function invocation, but it does puzzle me that the ordinary TKR rules do not seem to apply here. (Well, the “R” part does)