[Bug fortran/113254] Option -fallow-invalid-boz does not help with sample code
kargl at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sun Jan 7 01:43:08 GMT 2024
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113254
kargl at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kargl at gcc dot gnu.org
Priority|P3 |P4
--- Comment #1 from kargl at gcc dot gnu.org ---
-fallow-invalid-boz is not a panacea for invalid Fortran.
F2018 has
F2018:C7110 (R770) If type-spec is omitted, each ac-value expression
in the array-constructor shall have the same declared type and kind
type parameters.
F2018:C7111 (R770) If type-spec specifies an intrinsic type, each ac-value
expression in the array-constructor shall be of an intrinsic type that
is in type conformance with a variable of type type-spec as specified in
Table 10.8.
As a BOZ is typeless, it therefore cannot be in an array constructor.
Even if you had added a type-spec such as '[integer :: ...]'.
F2023 does allow a BOZ in an array constructor, with the following constraints:
F2023:C7126 If an ac-value is a boz-literal-constant, type-spec shall
appear and shall specify type integer or real.
F2023:C7127 If an ac-value is a boz-literal-constant and type-spec
specifies type real, the boz-literal-constant shall be a valid internal
representation for the specified kind of real.
Your code lacks a type-spec, so C7126 kicks in. Even with a type-spec,
as this is a new F2023 feature, gfortran does not currently support a BOZ
in an array-constructor.
Adding this capability would be a good introduction to contributing to
gfortran development.
More information about the Gcc-bugs
mailing list