From: Laurent <daemon2@internet.lu>
Subject: Re: Problem with generic linked list package
Date: Thu, 7 Aug 2014 12:07:15 -0700 (PDT)
Date: 2014-08-07T12:07:15-07:00 [thread overview]
Message-ID: <d5f90b52-9056-4472-a3ea-9cfaeff248ad@googlegroups.com> (raw)
In-Reply-To: <92dd7d22-a7da-44d7-9c40-b3aa62881683@googlegroups.com>
Hi
I have added an Insert_In_Order procedure to my generic package.
The normal version given by the book is working.
I have modified "Word" to "Element" so that it is generic.
Compiler wasn't happy because "<" and ">=" were not defined for Element_Type.
Ok so I added
function "<" (Left,Right: Element_Type) return Boolean is
begin
return Left< Right;
end "<";
function ">=" (Left,Right: Element_Type) return Boolean is
begin
return Left>= Right;
end ">=";
I got a warning about infinite recursion and the possibility of a stack overflow.
So I tested the package and I got a stack overflow.
I changed the 2 operators to:
function "<" (Left, Right : Element_Type) return Boolean is
begin
if Left < Right then
return True;
else
return False;
end if;
end "<";
function ">=" (Left, Right : Element_Type) return Boolean is
begin
if Left >= Right then
return True;
else
return False;
end if;
end ">=";
The warnings are gone but not the stack overflow.
The test program dies as soon as it gets to if Element < Head....
https://github.com/Chutulu/Chapter-15.git
Result of test_generic_linked_list.adb:
Content of L3
List is empty
inserting 5000 in L3
Content of L3
5000. . .
inserting 123 in L3
raised STORAGE_ERROR : stack overflow
[2014-08-07 21:05:15] process exited with status 1, elapsed time: 00.61s
Why do I get this error ?
Thanks
Laurent
next prev parent reply other threads:[~2014-08-07 19:07 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-28 13:26 Problem with generic linked list package Laurent
2014-07-29 7:51 ` Jacob Sparre Andersen
2014-07-29 8:12 ` Laurent
2014-07-29 8:27 ` Stephen Leake
2014-07-29 15:38 ` Laurent
2014-08-07 19:07 ` Laurent [this message]
2014-08-07 19:21 ` Adam Beneschan
2014-08-07 19:25 ` Adam Beneschan
2014-08-07 22:20 ` Laurent
2014-08-07 23:35 ` Adam Beneschan
2014-08-08 4:42 ` Laurent
2014-08-09 14:32 ` Laurent
2014-08-09 14:58 ` AdaMagica
2014-08-09 15:22 ` Jeffrey Carter
2014-08-09 18:51 ` Shark8
2014-08-09 21:53 ` Laurent
2014-08-09 22:25 ` Jeffrey Carter
2014-08-10 8:22 ` Simon Wright
2014-08-10 10:45 ` Simon Wright
2014-08-10 20:20 ` Laurent
2014-08-10 21:57 ` Simon Wright
2014-08-10 23:42 ` Jeffrey Carter
2014-08-11 4:51 ` Laurent
2014-08-11 5:13 ` Jeffrey Carter
2014-08-11 7:56 ` Laurent
2014-08-07 20:37 ` Shark8
2014-08-07 22:30 ` Laurent
2014-08-07 23:22 ` Shark8
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox