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

Fortran collective subroutines pass ERRMSG= by reference

Fixes libgfortran to pass the ERRMSG variable by reference for coarray collective subroutines, preventing crashes.

Coarray collective subroutines in Fortran, such as CO_BROADCAST and CO_REDUCE, incorrectly passed the ERRMSG= variable by value. This led to the library receiving the string length instead of a pointer, causing crashes when the ERRMSG variable was set, for example, when an image in a team stopped. The fix ensures ERRMSG= is passed by reference, aligning with how image control statements handle such variables.

In Details

The trans-intrinsic.cc file's conv_co_collective function has been updated to pass the errmsg argument by reference using gfc_conv_expr_reference. Previously, it was passed by value. This change corrects how error messages are handled for libgfortran's coarray collective subroutines, ensuring the library receives a valid pointer to the error message buffer.

For Context
coarray
A Fortran language feature that allows for parallel programming by providing a mechanism for images (concurrent processes) to directly access data on other images.
ERRMSG=
A Fortran standard argument for certain intrinsic procedures, including coarray collectives, used to return error messages. It expects a character variable.
by reference
Passing an argument to a function such that the function receives the memory address of the variable, allowing it to modify the original variable.
by value
Passing an argument to a function such that the function receives a copy of the variable's value. Modifications within the function do not affect the original variable.
Filed Under: fortrancoarraybugfix