GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
fortran

Fix ICE for dummy function returning CHARACTER(n)

Resolves compiler crash when handling CHARACTER dummy functions with dynamic lengths.

This commit fixes an Internal Compiler Error (ICE) in GCC’s Fortran front-end related to dummy functions that return a CHARACTER type with a length dependent on a function argument. The issue occurred because gfc_trans_deferred_vars incorrectly set up the result length, similar to how it handles CHARACTER dummy variables. Since the argument is not declared in the caller, this led to an assertion failure. The fix modifies the function to skip this setup for dummy functions, preventing the crash.

In Details

The gfc_trans_deferred_vars function in gcc/fortran/trans-decl.cc was incorrectly setting up the result length for CHARACTER dummy functions as if they were CHARACTER dummy variables. When the result length depended on a dummy argument of the function itself, this argument was not declared in the caller's scope, causing gfc_get_symbol_decl to fail an assertion. The fix ensures this setup is skipped for CHARACTER dummy functions, as their result length is evaluated at call time.

For Context
CHARACTER
A Fortran data type for representing strings of characters.
dummy function
In Fortran, a function that is declared but not defined within the program; it represents a function that will be provided externally.
dummy variable
In Fortran, a variable that is passed as an argument to a procedure and whose value may be modified by the procedure.
ICE
Internal Compiler Error. A serious error within the compiler itself that prevents it from completing compilation.
Filed Under: fortrancompiler-error