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

Re: Compiler does not compile valid code?

Mart van de Wege wrote:

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

I think this is a problem specific to your installation.

I copied the source from your example, and it seems to work fine in my Sid chroot:

% cat test_tree.adb
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);
   T.Insert_Child(Parent => C,
                  Before => No_Element,
                  New_Item => new String'("Test"));
end Test_Tree;
% gnatmake -gnata -gnato -fstack-check -gnat12 -gnatyO -gnatv -gnati1 -gnatf -gnatn -m test_tree.adb gcc-6 -c -gnata -gnato -fstack-check -gnat12 -gnatyO -gnatv -gnati1 -gnatf -gnatn test_tree.adb

GNAT 6.3.0 20170406
Copyright 1992-2016, Free Software Foundation, Inc.

Compiling: test_tree.adb
Source file time stamp: 2017-04-13 08:43:09
Compiled at: 2017-04-13 10:47:11
 14 lines: No errors
gnatbind-6 -x test_tree.ali
gnatlink-6 test_tree.ali -fstack-check
% ./test_tree
% echo $?
% dpkg -S $(which gnatmake)
gnat-6: /usr/bin/gnatmake


"Computer Science is to Science, as Plumbing is to Hydrodynamics"

Reply to: