GCC Newspaper
JUNE 15, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
ada

Fix issue with qualified expressions of class-wide types in Ada

Fixes a long-standing issue in Ada with qualified expressions of class-wide types that could lead to spurious errors.

This commit addresses a long-standing issue in the Ada compiler related to qualified expressions of class-wide types. The previous implementation failed to properly account for limited views of types when performing type compatibility analysis, potentially leading to spurious errors. The fix ensures an exact type match modulo the Non_Limited_View attribute, resolving the issue.

In Details

The issue resided in Analyze_Qualified_Expression within sem_ch4.adb. The Covers predicate, normally used for type compatibility, couldn't be applied to class-wide types due to name resolution rules. The fix now explicitly checks for an exact match modulo the Non_Limited_View attribute, ensuring correct type analysis.

For Context

In Ada, class-wide types represent the entire class hierarchy, similar to a base class pointer in C++. A qualified expression explicitly specifies the type of a value. This commit fixes a situation where the compiler could incorrectly flag errors when using qualified expressions with class-wide types, especially when dealing with types that have limited views (types that don't allow copying). The fix ensures the compiler performs accurate type checking in these cases.

Filed Under: adabugfixtype checking