[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Compiler does not compile valid code?



Hi,

I was doing some experimenting with Ada.Containers.Multiway_Trees.

However, even the most simple use case, compiling (using gnatmake
test_tree.adb, no switches) and running the following code on Sid,
raises a Program_Error:

raised PROGRAM_ERROR : Tree_Test.Test_Tree.Replace_Element: Position cursor designates root

with Ada.Text_Io;
with Ada.Containers.Multiway_Trees;
procedure Test_Tree is
   type String_Access is access String;
   package Tr is new Ada.Containers.Multiway_Trees
     ( Element_Type => String_Access );
   use Tr;
   T : Tree := Empty_Tree;
   C : Cursor := Root(T);
begin
   T.Insert_Child(Parent => C,
                  Before => No_Element,
                  New_Item => new String'("Test"));
end Test_Tree;

I asked in comp.lang.ada, and got confirmation from three other posters
there that this code compiles and runs fine for them, including someone
running Stretch.

What am I doing wrong here? Am I forgetting a compiler switch, or is
gnat in Sid broken?

Mart
-- 
"We will need a longer wall when the revolution comes."
    --- AJS, quoting an uncertain source.


Reply to: