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

C++: Fix ICE during explanation of failed __has_unique_object_representation

Fixes an internal compiler error related to explaining type information for __has_unique_object_representation.

This commit resolves an ICE (Internal Compiler Error) in GCC’s C++ frontend that occurred during the explanation of failed __has_unique_object_representation checks. The issue stemmed from incorrectly trying to get the source location of a type, which led to a crash. The fix involves using the location_of utility to correctly retrieve location information, preventing the ICE and ensuring accurate error reporting.

In Details

The record_has_unique_obj_representations function in tree.cc was incorrectly accessing DECL_SOURCE_LOCATION on a RECORD_TYPE or UNION_TYPE. This commit corrects it to use location_of(const_cast<tree>(t)), aligning with how location information is handled in similar functions like type_has_unique_obj_representations and preventing an ICE when explaining these type traits.

For Context
ICE
Internal Compiler Error. A condition where the compiler encounters an unrecoverable error during its execution, leading to a crash. This typically indicates a bug within the compiler itself.
__has_unique_object_representation
A C++ type trait that checks if a type has a unique object representation, meaning that two distinct objects of the type are guaranteed to have different memory representations. This is important for serialization and memory analysis.
location_t
A type used by GCC to represent source code locations, including file, line number, and column number. It's crucial for accurate error reporting and debugging information.
DECL_SOURCE_LOCATION
A macro in GCC's internal representation that retrieves the source code location associated with a declaration (DECL).
tree.cc
A source file within the GCC compiler responsible for handling the compiler's intermediate representation, known as GENERIC trees, and performing various tree-based transformations and analyses.
Filed Under: c++compiler bugice