GCC Newspaper
JULY 29, 2026
Date
/
Architectures
Components
Topics
News & Policy
c++

C++: Ensure type variants are consistent for trivial_abi

Fixes C++ type consistency for trivial_abi by applying attribute removal to all variants.

This commit addresses an inconsistency in C++ type handling for the trivial_abi attribute. Previously, removing this attribute from only the main type could lead to qualified variants having different attributes, even though they shared a canonical type. The fix ensures the rejected attribute is removed from all variants, maintaining type consistency.

In Details

When the trivial_abi attribute is rejected for a type, GCC's type variant system could previously leave the attribute on qualified variants (e.g., const T, volatile T) even if it was removed from the base type T. This commit modifies validate_trivial_abi_attribute in tree.cc to iterate through all type variants and remove the rejected attribute from each, ensuring canonical type consistency.

For Context
trivial_abi
An attribute that specifies that a type has a trivial 'C' calling convention. This can allow for certain optimizations in function calls and data passing.
type variant
In C++, different forms of a type that share a common underlying definition, such as pointers, references, qualified (const/volatile) versions of a base type, or template instantiations.
canonical type
The underlying, fundamental type definition from which other related types (variants) are derived. For example, 'int' is the canonical type for 'int', 'const int', and 'volatile int'.
Filed Under: c++type system