https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124369
Bug ID: 124369
Summary: [13/14/15/16 regression] missing error for dangling
pointer from access discriminant
Product: gcc
Version: 13.4.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: ada
Assignee: unassigned at gcc dot gnu.org
Reporter: ebotcazou at gcc dot gnu.org
CC: dkm at gcc dot gnu.org
Target Milestone: ---
The following procedure used to be rejected with:
p.adb:20:15: non-local pointer cannot point to local object
but is now accepted by the compiler and runs quietly:
with Ada.Text_IO; use Ada.Text_IO;
procedure P is
type Rec (Element : access Integer) is null record;
function Make_Rec (X : access Integer) return Rec is (Element => X);
type Acc is access all Integer;
A : Acc;
begin
for I in 1 .. 10 loop
declare
X : aliased Integer;
R : Rec := Make_Rec (X'Access);
begin
if I = 1 then
X := 0;
end if;
A := R.Element.all'Access;
Put_Line (A.all'Image);
X := I;
end;
end loop;
Put_Line (A.all'Image);
end;