-- Shows two procedures sharing the same memory locations on the stack
-- Uninitialized variable uses the value left over from previous call
with Unchecked_Conversion;
with Text_IO; use Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
procedure uninitlocals is
    type AddressType is mod 2**32;
    package Address_IO is new Text_IO.Modular_IO (Num => AddressType);
    use Address_IO;

    procedure put_line(s: String; a: AddressType) is 
    begin put(s); put(a, width=>1, base=>16); new_line; end put_line;

    procedure putlocaladdr1 is
        a: aliased integer := 99;
        type IntPointer2 is access all Integer;
        function Convert is new Unchecked_Conversion(IntPointer2, AddressType);
    begin
        put_line("address of a: ",  convert(a'access));
        put_line("value of a: " & a'img);
    end putlocaladdr1;

    procedure putlocaladdr2 is
        b: aliased integer;  -- Uninitialized
        type IntPointer3 is access all Integer;
        function Convert is new Unchecked_Conversion(IntPointer3, AddressType);
    begin
        put_line("address of b: ",  convert(b'access));
        put_line("value of b: " & b'img);
    end putlocaladdr2;

begin
    putlocaladdr1;
    putlocaladdr2;
end uninitlocals;
-- address of a: 16#BFA8E3AC#
-- value of a:  99
-- address of b: 16#BFA8E3AC#
-- value of b:  99