From: Vratislav Podzimek <vratislav.podzimek@gmail.com>
Subject: Bug in GNAT? - Max_size_in_storage_elements insufficient
Date: Tue, 18 Oct 2016 11:17:37 +0000 (UTC)
Date: 2016-10-18T11:17:37+00:00 [thread overview]
Message-ID: <nu50ch$1q33$1@gioia.aioe.org> (raw)
When trying to set Storage_Size for tasks or records I'm getting a crash
indicating that the Max_size_in_storage_elements attribute doesn't seem
to provide the correct value. Here are the simple reproducers:
1) task type
with Ada.Text_Io; use Ada.Text_Io;
procedure Task_Storage_Size is
task type My_Task (Id : Natural); -- works just fine without the
discriminant
task body My_Task is
X : Natural := Id;
begin
X := X ** 10;
Put_Line ("ID : " & Natural'Image (Id));
end;
type My_Task_Access is access My_Task
with Storage_Size => 4 * My_Task'Max_size_in_storage_elements; --
Crashes
-- with Storage_Size => 6 * My_Task'Max_size_in_storage_elements; --
Doesn't crash.
type My_Task_Array is array (Natural range <>) of My_Task_Access;
Tasks : My_Task_Array (1..4);
begin
-- raises STORAGE_ERROR : s-poosiz.adb:259 explicit raise
for I in Tasks'Range loop
Tasks (I) := new My_Task (I);
end loop;
end;
2) record type:
procedure Record_Storage_Size is
type My_Record is
record
X : Natural := 0;
end record;
type My_Record_Access is access My_Record
with Storage_Size => 4 * My_Record'Max_size_in_storage_elements; --
crashes
-- with Storage_Size => 8 * My_Record'Max_size_in_storage_elements;
-- doesn't crash
type My_Record_Array is array (Natural range <>) of My_Record_Access;
Records : My_Record_Array (1..4);
begin
-- raises STORAGE_ERROR : s-poosiz.adb:108 explicit raise
for I in Records'Range loop
Records (I) := new My_Record;
end loop;
end;
To safe us from a potential discussion that has already happened on IRC,
here's the related chunk from the RM:
"If Storage_Size is specified for an access type, then the Storage_Size
of this pool is at least that requested, and the storage for the pool is
reclaimed when the master containing the declaration of the access type
is left"
So Storage_Size specification for an access type specifies the amount of
space for the allocated objects of the accessed type. However, it can
also be used for a task type (not access to a task type) to specify the
amount of space for a task's stack.
Or am I missing something?
next reply other threads:[~2016-10-18 11:17 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-18 11:17 Vratislav Podzimek [this message]
2016-10-18 12:35 ` Bug in GNAT? - Max_size_in_storage_elements insufficient Dmitry A. Kazakov
2016-10-18 15:26 ` Vratislav Podzimek
2016-10-18 16:03 ` Dmitry A. Kazakov
2016-10-19 1:39 ` Luke A. Guest
2016-10-19 7:33 ` Dmitry A. Kazakov
2016-10-20 0:59 ` Randy Brukardt
2016-10-19 15:45 ` Eryndlia Mavourneen
2016-10-19 15:53 ` Eryndlia Mavourneen
2016-10-19 13:34 ` Egil H H
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox