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

Fixes `Valid_Scalars` attribute for private tagged types

This commit resolves an issue where the Ada `Valid_Scalars` attribute failed to work correctly with certain private tagged types.

The GCC Ada compiler now correctly handles the Valid_Scalars attribute for private tagged types, specifically addressing cases where only the full view of the type is tagged. Previously, the attribute’s checks would incorrectly fail in such scenarios, leading to compiler errors. This fix ensures the attribute works as intended across a wider range of private tagged type configurations, improving reliability for developers using this feature.

In Details

The Valid_Scalars attribute in Ada is used to ascertain if the scalar components of a type hold valid values. This commit addresses a specific bug (PR ada/124923) related to its application on private tagged types—types whose full definition is not visible to the user but which are declared as tagged. The problem arose when only the 'full view' (internal definition) of a private type was marked as tagged, causing the attribute's logic in exp_attr.adb and sem_attr.adb to incorrectly reject it. The fix extends the internal checks to properly account for these types, preventing spurious…

For Context

In Ada, 'private types' are used to hide the internal details of a data structure from other parts of the program, promoting good software design. 'Tagged types' are a more advanced feature, similar to classes in other languages, that allow for flexible, extensible data structures. The Valid_Scalars attribute is a special check you can ask the compiler to perform to ensure that individual numbers (scalar values) within your data structures are always within their allowed ranges. This change in the GCC Ada compiler fixes a problem where this Valid_Scalars check wasn't working correctly for certain kinds of private tagged types. Specifically, if a type was declared as private but internally designed to be 'tagged', the compiler would incorrectly flag errors. This update makes the compiler's checks more robust, allowing developers to use this important validation attribute with a broader range of Ada type definitions.

Filed Under: bugfixadatype-system