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

Ada: Fix wild memory access for pragma Warnings (On|Off, "*")

Fixes wild memory access in Ada compiler when pragmas handle all warnings.

A wild memory access occurred in the Ada compiler when using pragma Warnings (On|Off, "*"), particularly when such pragmas were located in configuration files. The issue arose because Find_Direct_Name attempted to manually walk the scope stack while it was still empty. This commit adds a necessary guard to prevent this manual stack walk under such conditions.

In Details

This patch addresses a memory corruption issue in GCC's Ada semantic analyzer (sem_ch8.adb) when processing pragma Warnings (On|Off, '*'). The problem occurs when this pragma is encountered in a configuration file, causing Find_Direct_Name to improperly access the scope stack before it's fully established. A guard condition is added to prevent the manual scope stack traversal in this specific scenario, ensuring correct initialization and preventing the memory access violation.

For Context
pragma
A directive or instruction within a source code file that provides information to the compiler, often controlling aspects of compilation or language behavior that are not part of the core syntax.
Warnings (On|Off, "*")
An Ada pragma used to control compiler warning messages. On or Off specifies whether to enable or disable warnings, and * signifies that the directive applies to all warning categories.
configuration file
A file used to store settings or parameters that customize the behavior of a program or system. In this context, it likely refers to a file where GCC's Ada front-end settings or pragmas are predefined.
wild memory access
An error where a program attempts to read from or write to a memory location that it has not been allocated or is not supposed to access. This can lead to data corruption, crashes, or security vulnerabilities.
scope stack
A data structure used by compilers to keep track of the current visibility and accessibility of identifiers (variables, functions, types) within different blocks of code.
Filed Under: adacompiler bugmemory safetypragma