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

Fix internal error on private tagged types in instance with -gnateV.

An internal compiler error with private tagged types and `-gnateV` in Ada generics is resolved.

This commit fixes an internal compiler error that occurred in Ada when using private tagged types within generic instances compiled with the -gnateV switch. The problem stemmed from the compiler failing to correctly restore the full view of a private tagged type during the expansion of generic instances. The fix involves adjusting the Valid_Scalars attribute’s handling of tagged extensions and extending the special case for selected components in instances to cover whole instances, ensuring proper type validation and avoiding crashes.

In Details

The Ada front-end was encountering an internal error (PR ada/124923) when -gnateV (validity checking) was applied to instances of generics containing private tagged types. The root cause was exp_attr.adb and sem_attr.adb failing to correctly restore the full type view of private tagged types when expanding generic instances, particularly within the context of the Valid_Scalars attribute. The fix involves two parts: Build_Record_VS_Func in exp_attr.adb is updated to correctly handle tagged extensions, and Try_Selected_Component_In_Instance in sem_ch4.adb is extended to apply th…

For Context

In Ada, 'generics' are templates for code that can work with different types, and 'tagged types' are similar to classes in object-oriented programming that support inheritance. 'Private types' are types whose internal structure is hidden from most of your program. This commit fixes a bug in the Ada compiler (GCC) that caused it to crash an internal error when you tried to use private tagged types inside a generic code template, and then instantiated that template while also using the -gnateV compiler option. The -gnateV option is for rigorous validity checking, ensuring that data is within its expected range. The crash happened because the compiler wasn't correctly seeing the full details of the private tagged type when it expanded the generic code. The fix makes the compiler smarter about how it checks the validity of these complex types within generics, preventing the crash and ensuring the validity checks work as intended.

Filed Under: adabugfixgenericstype-system