Created
October 13, 2016 07:16
-
-
Save vpodzime/cd8b0e3482aff21e88dd03386a03490a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
end; | |
type My_Task_Access is access My_Task | |
with Storage_Size => 4 * My_Task'Max_size_in_storage_elements; | |
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; |
Good point, thanks!
I also tested the above with records and it's even worse:
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;
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'd put this version up: