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

The Ada front end fixes missing error for deep access results in generics

The Ada front end now correctly identifies and flags errors when generic functions declare deeply nested access types, enforcing proper accessibility rules.

This commit fixes a missing error detection in the Ada front end for cases where generic functions declare access results with too deep an accessibility level. The problem stemmed from the Is_Local_Anonymous_Access flag not being set correctly for anonymous access types in generic function specifications. The fix involves properly setting this flag in sem_ch12.adb during generic subprogram analysis, dealing with formal objects of generic subprograms in Accessibility_Level, and making corrections in the GNAT.CPP_Exceptions runtime unit to prevent illegal code and ensure proper handling of access-to-tagged-object declarations.

In Details

The gcc/ada subsystem handles the Ada front end for GCC. This commit addresses a subtle bug related to accessibility level checks for anonymous access types returned by generic subprograms. In Ada, accessibility levels are crucial for ensuring type safety, particularly with 'access types' (pointers/references) and 'anonymous access types' (access types without an explicit name). The issue was that the Is_Local_Anonymous_Access flag, vital for these checks, was not being correctly set during the analysis of generic function specifications (Analyze_Generic_Subprogram_Declaration in `sem_c…

For Context

The Ada front end in the GCC compiler analyzes your Ada code. A key part of Ada's safety features involves 'accessibility levels,' which dictate how long a 'pointer' or 'reference' (called an 'access type' in Ada) can safely refer to an object. This is especially important for 'anonymous access types' that are created on the fly. This commit fixes a bug where the compiler was failing to report an error when a generic function (a function that works with different types, like a C++ template) would return an access type that could point to data with too short a lifespan, which is unsafe. The compiler was not correctly marking these anonymous access types, preventing it from catching these potential errors. The fix ensures that these access types are properly identified during the analysis of generic subprograms, improving the compiler's ability to enforce Ada's safety rules and catching subtle program errors that could lead to crashes or incorrect behavior. Additionally, it corrects som…

Filed Under: adabugfixtype-safetygenerics