Home | History | Annotate | Line # | Download | only in varsize_limit
      1 --  Copyright 2018-2024 Free Software Foundation, Inc.
      2 --
      3 --  This program is free software; you can redistribute it and/or modify
      4 --  it under the terms of the GNU General Public License as published by
      5 --  the Free Software Foundation; either version 3 of the License, or
      6 --  (at your option) any later version.
      7 --
      8 --  This program is distributed in the hope that it will be useful,
      9 --  but WITHOUT ANY WARRANTY; without even the implied warranty of
     10 --  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     11 --  GNU General Public License for more details.
     12 --
     13 --  You should have received a copy of the GNU General Public License
     14 --  along with this program.  If not, see <http://www.gnu.org/licenses/>.
     15 
     16 with Pck; use Pck;
     17 with System;
     18 with Unchecked_Conversion;
     19 
     20 procedure VsizeLim is
     21    Small : String := Ident ("1234567890");
     22    Larger : String := Ident ("1234567890|1234567890|1234567890");
     23 
     24    type String_Ptr is access all String;
     25    type Big_String_Ptr is access all String (Positive);
     26 
     27    function To_Ptr is
     28      new Unchecked_Conversion (System.Address, Big_String_Ptr);
     29 
     30    Name_Str : String_Ptr := new String'(Larger);
     31    Name : Big_String_Ptr := To_Ptr (Name_Str.all'Address);
     32 
     33    type Table is array (Positive range <>) of Integer;
     34    type Object (N : Integer) is record
     35        Data : Table (1 .. N);
     36    end record;
     37 
     38    BA : Object := (N => 1_000_000, Data => (others => 0));
     39 
     40 begin
     41    for I in 1 .. 10 loop
     42       BA.Data(I) := I;
     43    end loop;
     44 
     45    Do_Nothing (Small'Address); -- STOP
     46    Do_Nothing (Larger'Address);
     47    Do_Nothing (Name'Address);
     48    Do_Nothing (BA'Address);
     49 end VsizeLim;
     50