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=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: [Bounded] Vectors, reference types, and the secondary stack Date: Sun, 15 Feb 2015 16:21:43 +0000 Organization: A noiseless patient Spider Message-ID: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="4eba6dd55c03f4a8d448cad2a88d67ef"; logging-data="25317"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18gwcE0ds0Lcg4v7XDWzGvGxWO+YW0x65g=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (darwin) Cancel-Lock: sha1:BR6fxr/Tk9TGS5ZOnkZED95prtk= sha1:zVXyDFc4nKZimwx72PSjEzUYxbs= Xref: news.eternal-september.org comp.lang.ada:24967 Date: 2015-02-15T16:21:43+00:00 List-Id: It turns out that (GCC 4.9.1) that if you have package Interval_Containers is new Ada.Containers.Bounded_Vectors (Index_Type => Natural, Element_Type => Ada.Real_Time.Time_Span, "=" => Ada.Real_Time."="); Intervals : Interval_Containers.Vector (5); and then Intervals.Insert_Space (0, 5); Intervals (0) := Ada.Real_Time.Milliseconds (50); then function Reference (Container : aliased in out Vector; Index : Index_Type) return Reference_Type; returns its result on the secondary stack! Why would it need to do that? given the (private) definition type Reference_Type (Element : not null access Element_Type) is null record; You ask why I would care. Well, in my STM32F4 RTS the environment task, in which elaboration happens, isn't actually a task, and doesn't (yet) have a secondary stack. The reason it's not a task is that the way to kick off the FreeRTOS sceduler is to call FreeRTOS.Tasks.Start_Scheduler (aka vTaskStartScheduler()), which doesn't return unless the scheduler can't be started; and I haven't found a way to get this behaviour into the startup code generated by gnatbind, so the poor user has to call it at the end of their main program.