https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125560
Bug ID: 125560
Summary: [PDT] rejects valid default initialization
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: neil.n.carlson at gmail dot com
Target Milestone: ---
I'm dipping my toes into PDT again and I encountered a problem illustrated by
this example:
type :: foo(ik)
integer, kind :: ik
integer(ik) :: p = 0 ! VALID BUT REJECTED
integer(ik) :: q = 0_ik ! INVALID(?) AND REJECTED
integer(ik) :: r = integer(0, kind=ik) ! VALID AND ACCEPTED
end type
end
example.f90:4:26:
4 | integer(ik) :: q = 0_ik ! INVALID(?) AND REJECTED
| 1
Error: Missing kind-parameter at (1)
example.f90:3:20:
3 | integer(ik) :: p = 0 ! VALID BUT REJECTED
| 1
Error: Cannot convert INTEGER(4) to INTEGER(0) at (1)
I question the validity of the "q = 0_ik" expression, because NAG also rejected
it.
But ifx and flang-new both accept it. However I'm now mostly convinced that it
is invalid
because while in the scope of the derived-type definition it can be used as a
primary in a constant expression (7.5.3.1 par 5), it is itself not a named
constant.