From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: Vratislav Podzimek Newsgroups: comp.lang.ada Subject: Bug in GNAT? - Max_size_in_storage_elements insufficient Date: Tue, 18 Oct 2016 11:17:37 +0000 (UTC) Organization: Aioe.org NNTP Server Message-ID: NNTP-Posting-Host: ONPcOm8flCRYsdvOmHwGzA.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@aioe.org User-Agent: Pan/0.140 (Chocolate Salty Balls; GIT b8fc14e git.gnome.org/git/pan2) X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:32116 Date: 2016-10-18T11:17:37+00:00 List-Id: 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?