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

Fortran parameterized derived types now handle intent(out) arguments correctly.

Fixes errors in Fortran parameterized derived types when used with intent(out) arguments, improving type checking and initialization.

This change resolves issues related to parameterised derived types (PDTs) in Fortran when used with intent(out) dummy arguments. It enhances the structure_alloc_comps and gfc_check_pdt_dummy functions to correctly handle components with codimensions, pointers, or parameterised kinds, ensuring proper initialization and type checking. The changes also ensure that deferred initializations are handled correctly for these scenarios.

In Details

This commit revises gcc/fortran/trans-array.cc and related headers to correctly handle Parameterized Derived Types (PDTs) with intent(out) dummy arguments, addressing PR fortran/82173. The key changes involve modifying structure_alloc_comps to properly check and set components when intent_out is true, and introducing a new intent_out argument to gfc_check_pdt_dummy. It also updates gfc_trans_deferred_vars to handle gfc_defer_symbol_init for these cases, including using gfc_conv_expr_present for optional arguments.

For Context
Parameterized Derived Type (PDT)
A derived type in Fortran whose kind or length type parameters can be specified at the time of variable declaration, allowing for more flexible and generic type definitions.
intent(out)
A Fortran procedure argument attribute indicating that the argument is intended to receive a value from the procedure. The initial value of such arguments is undefined upon entry to the procedure.
dummy argument
In Fortran, a variable listed in the procedure's interface that represents an argument passed from the caller.
codimension
In Fortran, refers to the rank of an array section or a coarray, distinguishing it from the array's full rank.
structure constructor
A Fortran construct used to initialize or create a derived type variable by specifying values for its components.
Filed Under: fortranpdtderived types