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

fortran: Fixes INTENT(IN) error for POINTER selector in CLASS IS

Corrects a false INTENT(IN) error when a POINTER dummy argument is used as a selector in a CLASS IS block.

This change fixes a bug where the Fortran compiler incorrectly issued an INTENT(IN) error for POINTER dummy arguments used as selectors in CLASS IS blocks. The compiler was checking the associate name’s POINTER attribute instead of the dummy argument’s, leading to this false positive. The fix ensures the check correctly targets the dummy argument, resolving the issue for polymorphic POINTER INTENT(IN) arrays as well.

In Details

The gfc_check_vardef_context in Fortran's expr.cc was misinterpreting the INTENT(IN) constraint when applied to a CLASS IS block whose selector is a POINTER dummy. Due to a fix for PR54322, it incorrectly rejected constructs where the associate name inherited the POINTER attribute from its class container. This commit modifies the check to examine the POINTER attribute of the dummy argument itself, rather than the associate name, resolving the incorrect rejection.

For Context
INTENT(IN)
An attribute in Fortran that specifies a dummy argument must not be modified by the procedure.
POINTER
A Fortran attribute that designates a variable as a pointer, capable of target association.
CLASS IS block
A Fortran construct used for type discrimination, selecting code paths based on the dynamic type of an object.
selector
In a CLASS IS block, the expression whose dynamic type determines which branch is taken.
associate name
A temporary name introduced within a SELECT TYPE or CLASS IS construct to refer to the selector.
Filed Under: fortrantype checkingpointer