https://gcc.gnu.org/g:8f459cebbd1e14905e4925aba42c1ade0c9a2040

commit r14-12917-g8f459cebbd1e14905e4925aba42c1ade0c9a2040
Author: Eric Botcazou <[email protected]>
Date:   Wed Oct 7 21:22:28 2026 +0200

    Ada: Fix wild memory access for pragma Warnings (On|Off, "*")
    
    This occurs when the pragma is in a configuration file.  The problem is that
    Find_Direct_Name manually walks the scope stack while it is still empty.
    
    gcc/ada/
            PR ada/126125
            * sem_ch8.adb (Find_Direct_Name): Add missing guard to the manual
            walk of the scope stack used to cope with the Rtsfind mechanism.

Diff:
---
 gcc/ada/sem_ch8.adb | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb
index 125ccc6c433a..5971caa0bd9c 100644
--- a/gcc/ada/sem_ch8.adb
+++ b/gcc/ada/sem_ch8.adb
@@ -6359,6 +6359,7 @@ package body Sem_Ch8 is
 
          Level := Scope_Stack.Last;
          loop
+            exit when Level < 0;
             Scop := Scope_Stack.Table (Level).Entity;
             exit when Scop = Scope (E);
             Level := Level - 1;

Reply via email to