GCC Newspaper
JULY 29, 2026
Date
/
Architectures
Components
Topics
News & Policy
fortran

Fortran: Fix character function invocation as stop code

Fortran compiler now correctly handles character functions used as STOP codes, per F2008 standard.

The Fortran compiler (gfortran) has been fixed to correctly handle character functions invoked as stop codes, aligning with the F2008 standard. Previously, the compiler would reject valid character function invocations, leading to incorrect error checking. This patch adjusts the matching and resolving logic to allow these constructs and checks them later in the resolution phase.

In Details

Addresses PR fortran/126018 by modifying gfc_match_stopcode in match.cc and gfc_resolve_code in resolve.cc. The change relaxes the error check in gfc_match_stopcode to not error if the STOP code expression's type is unknown, deferring the check to gfc_resolve_code. The latter function is updated to add specific checks for EXEC_STOP and EXEC_ERROR_STOP associated with character expressions.

For Context
STOP code
An optional integer or character expression used in a Fortran STOP statement to provide a message or status code when program execution terminates.
Character function
In Fortran, a function that returns a character string value.
gfortran
The GNU Fortran compiler, part of the GNU Compiler Collection (GCC).
F2008
Fortran 2008, a revision of the Fortran programming language standard.
Filed Under: fortrancompilerstandard conformance