https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124054
Bug ID: 124054
Summary: bug box from itype as subpool expression when a custom
allocate procedure is generated
Product: gcc
Version: 15.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: ada
Assignee: unassigned at gcc dot gnu.org
Reporter: liam at liampwll dot com
CC: dkm at gcc dot gnu.org
Target Milestone: ---
The issue here is that Build_Allocate_Deallocate_Proc calls New_Copy_Tree on
the subpool expression without New_Scope, which means the first usage of the
relevant itype is in a different scope.
Reproducer below:
with System.Storage_Pools.Subpools; use System.Storage_Pools.Subpools;
with Ada.Finalization; use Ada.Finalization;
procedure Example is
type My_Subpool_Type is new Root_Subpool with null record;
type My_Subpool_Access_Type is access all My_Subpool_Type;
My_Subpool : aliased My_Subpool_Type;
My_Subpool_Access : Subpool_Handle := My_Subpool'Unrestricted_Access;
My_Subpool_Access_2 : access My_Subpool_Type := My_Subpool'Access;
type Controlled_Type is new Ada.Finalization.Controlled with null record;
A : access Controlled_Type :=
new (Subpool_Handle'(My_Subpool'Unrestricted_Access)) Controlled_Type;
B : access Controlled_Type := new (My_Subpool_Access) Controlled_Type;
C : access Controlled_Type := new (My_Subpool_Access_2) Controlled_Type;
D : access Controlled_Type := new (My_Subpool'Access) Controlled_Type;
-- Line 19 above.
begin
null;
end Example;
+===========================GNAT BUG DETECTED==============================+
| 16.0.1 20260210 (experimental) (x86_64-linux-gnu) GCC error: |
| in gnat_to_gnu_entity, at ada/gcc-interface/decl.cc:400 |
| Error detected at example.adb:19:34 |
| 15.2.0 (x86_64-linux-gnu) GCC error: |
| in gnat_to_gnu_entity, at ada/gcc-interface/decl.cc:392 |
| Error detected at example.adb:19:34 |