GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
ada

Ada compiler fixes memory leak in finalizable type post-conditions

Fixes a memory leak in Ada's handling of 'Old of finalizable types in conditionally evaluated post-conditions.

This Ada compiler patch resolves a memory leak that occurred when using the ’Old attribute on finalizable types within conditionally evaluated post-conditions. Previously, temporaries holding the old value were incorrectly allocated on the heap instead of the secondary stack, leading to leaks. The fix redirects these allocations to the secondary stack.

In Details

The GCC Ada runtime library (libgnat) has a special mechanism for handling 'Old of a finalizable type within a conditionally evaluated post-condition. This commit corrects an implementation detail where the temporary storage for the old value was allocated on the main heap instead of the designated secondary stack. By generating a call to SS_Allocate_Any_Controlled for the secondary stack pool, the memory leak is resolved.

For Context
Ada
A structured, statically typed, imperative programming language designed for reliability and efficiency, often used in high-integrity systems.
finalizable type
In Ada, a type whose objects require a finalization procedure to be called when they go out of scope or are deallocated.
post-condition
A condition that must be true after a subprogram (function or procedure) has executed.
'Old attribute
In Ada, used in pre- or post-conditions to refer to the value of a variable before the subprogram's execution.
memory leak
A situation where a program allocates memory but fails to deallocate it when it's no longer needed, eventually consuming available memory.
secondary stack
A specific memory area, potentially managed differently from the main call stack, used by Ada's runtime for certain temporary allocations.
Filed Under: adamemory leakruntime