GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
c++/modules

C++ modules ICE fixed for GMF variables defined inline

Fixes an ICE in C++ modules when GMF variables are later defined inline.

An internal compiler error (ICE) in GCC’s C++ modules feature has been fixed. The issue occurred when a redeclaration of a variable had language-specific data allocated, but the original declaration did not. This change ensures that language-specific data is correctly allocated using retrofit_lang_decl for such cases, resolving the ICE and improving module handling for inline definitions.

In Details

This commit addresses PR c++/126783 by correcting transfer_defining_module in module.cc. The function previously assumed that if a redeclaration had DECL_LANG_SPECIFIC allocated, the original declaration must also have it. This assumption failed for the q variable in the testcase. The fix is to call retrofit_lang_decl to allocate DECL_LANG_SPECIFIC as needed, mirroring behavior in duplicate_decls and ensuring correct language-specific data handling for GMF variables.

For Context
C++ modules
A feature in C++ (and thus GCC) that provides an alternative to header files for organizing code, aiming for faster compilation times and better encapsulation.
ICE
Internal Compiler Error. A condition where the compiler encounters an unrecoverable error in its own logic and terminates.
GMF
GCC Module Format. The internal representation used by GCC for C++ modules.
DECL_LANG_SPECIFIC
A flag or field in GCC's internal data structures that indicates language-specific information is associated with a declaration.
retrofit_lang_decl
A GCC internal function used to ensure that language-specific data structures are allocated for a declaration if they don't already exist.
Filed Under: c++modulescompiler error