Warn on insufficient real output field widths in Fortran
Gfortran now warns at compile time about real output field widths that are too small.
Gfortran will now issue a compile-time warning when a real number output format string has a field width too small to accommodate the number’s digits. This warning is enabled by default via -Wall and is triggered by the new -Wformat-width option. The check is performed in two passes to handle labeled FORMAT statements correctly.
In Details
This patch introduces compile-time checks for real output edit descriptors (D, E, EN, ES, F, G) in Fortran. The check_format routine now accepts a format_check_kind argument. A first pass (FMT_CHECK_DECL) skips width checks when I/O direction is unknown. A second pass (FMT_CHECK_WIDTH), triggered by gfc_resolve_dt upon first output use, specifically verifies that the specified field width is sufficient for the number of digits. This addresses PR45129.
- edit descriptor
- A component of a Fortran FORMAT statement that specifies how to format I/O data, such as
Dfor real numbers,Ifor integers, orAfor character strings. - FORMAT statement
- A Fortran statement used to define the format for input and output operations, specifying how data should be read or written.
- gfortran
- The GNU Fortran compiler, part of the GNU Compiler Collection (GCC).