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

i386: Move scalar_chain classes to i386-features.cc

Scalar chain classes are moved to their sole user file to resolve ODR violations.

The scalar_chain, general_scalar_chain, and timode_scalar_chain classes have been moved from i386-features.h to i386-features.cc. This resolves an One Definition Rule (ODR) violation that occurred when i386.cc also included i386-features.h, leading to issues with other compilers.

In Details

Following the split of i386.c into i386.cc and i386-features.h, the scalar_chain related classes were moved to the header. This created an ODR violation because i386.cc also includes i386-features.h. The anonymous namespace in the header caused these classes to have internal linkage, but their non-pure virtual members were ODR-used in i386.cc without being defined in that translation unit. Moving these classes back into i386-features.cc, their only user, resolves this issue by ensuring they are defined and used within a single translation unit.

For Context
One Definition Rule (ODR)
A rule in C++ that states any non-inline function or variable must have exactly one definition in the entire program. Violating ODR can lead to undefined behavior or linking errors.
internal linkage
A linkage specification where an identifier is only visible within the translation unit (source file) in which it is defined. Anonymous namespaces provide internal linkage.
ODR-used
An entity (like a function or variable) is ODR-used if its definition is required by the C++ language rules, even if it's not directly called or accessed in the visible code. For example, a non-inline function with external linkage is ODR-used if it's ever taken the address of or called.
translation unit
A single source file after all preprocessing directives (like #include) have been processed. Compilers typically compile one translation unit at a time.
Filed Under: i386internalODR violation