Hello,
Assume this code snippet:
pragma Ada_2022;
with Ada.Text_IO;
with Ada.Containers.Ordered_Sets;
use Ada.Containers;
procedure Test9 is
package set1_p is new Ordered_Sets (Element_Type => Natural);
use set1_p;
function aset1(s : set1_p.Set) return set1_p.Set is separate;
-- function aset1(s : set1_p.Set) return set1_p.Set is
-- begin
-- return s : constant set1_p.Set := [1, 2, 3] do
-- null;
-- end return;
-- end aset1;
s : constant set1_p.Set := aset1([1,2,3]);
begin
Ada.Text_IO.Put_Line ("s : " & s'Image);
end Test9;
with the separate part:
pragma Ada_2022;
separate (test9)
function aset1(s : set1_p.Set) return set1_p.Set is
begin
return s : constant set1_p.Set := [1, 2, 3] do
null;
end return;
end aset1;
I get this error message when trying to compile:
Compile
[Ada] test9.adb
+===========================GNAT BUG DETECTED==============================+
| 14.2.0 (x86_64-pc-linux-gnu) Storage_Error stack overflow or erroneous memory access|
| Error detected at test9-aset1.adb:5:6 |
| Compiling /home/reinert/test9/src/test9.adb |
| Please submit a bug report; see GCC Bugs - GNU Project . |
| Use a subject line meaningful to you and us to track the bug. |
| Include the entire contents of this bug box in the report. |
| Include the exact command that you entered. |
| Also include sources listed below. |
+==========================================================================+
When I avoid to separate (but include the function in the main file), then the compiler does not complain.
Edit: forgot to say that this error appears under gnat 14.2.1 (not under 13.2.1)
reinert