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

Ada fixes internal error on abstract primitive with access result

GCC's Ada front end correctly sets the scope for derived subprogram access types, resolving an internal error.

This commit corrects an internal error in the Ada front end related to abstract primitive subprograms returning access types. The previous fix addressed a symptom, but the root cause stemmed from incorrectly assigning the subprogram itself as the scope for the anonymous access result type of derived subprograms. The compiler now correctly assigns the scope of the new anonymous access type to the scope of the derived type, preventing compiler crashes.

In Details

In the GCC Ada front end, particularly in accessibility.adb and sem_ch3.adb, the compiler constructs internal type representations for anonymous access types, often arising from derived subprograms. The bug involved the Scope attribute of these temporary types: previously, it was erroneously set to the subprogram itself (Entity), rather than the Scope of the derived type. This commit reverts a prior symptomatic fix in Type_Access_Level and correctly sets the Scope of the new anonymous access type during Derive_Subprogram.Replace_Type, ensuring proper type accessibility analysi…

For Context

Compilers generate internal representations of your code, including types and where they are defined, which is called their 'scope.' This commit fixes a deep-seated bug in the Ada compiler (part of GCC) that caused it to crash when dealing with certain advanced features: 'abstract primitive subprograms' that return 'access types' (Ada's equivalent of pointers or references). The compiler was confused about the 'scope' (the region of the program where a type is valid) of these special return types. It was incorrectly assigning the subprogram itself as the scope, instead of the broader scope of the type it was derived from. This fix ensures the compiler correctly understands the lifetime and visibility of these internal types, preventing it from crashing.

Filed Under: adabugfixcompiler internals