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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.236.112.6 with SMTP id x6mr2286344yhg.42.1407438435837; Thu, 07 Aug 2014 12:07:15 -0700 (PDT) X-Received: by 10.140.36.198 with SMTP id p64mr52673qgp.10.1407438435817; Thu, 07 Aug 2014 12:07:15 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!peer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!j15no5353293qaq.0!news-out.google.com!j6ni34691qas.0!nntp.google.com!v10no5282917qac.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 7 Aug 2014 12:07:15 -0700 (PDT) In-Reply-To: <92dd7d22-a7da-44d7-9c40-b3aa62881683@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=87.240.202.21; posting-account=sDyr7QoAAAA7hiaifqt-gaKY2K7OZ8RQ NNTP-Posting-Host: 87.240.202.21 References: <85a97spo1c.fsf@stephe-leake.org> <92dd7d22-a7da-44d7-9c40-b3aa62881683@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Problem with generic linked list package From: Laurent Injection-Date: Thu, 07 Aug 2014 19:07:15 +0000 Content-Type: text/plain; charset=ISO-8859-1 X-Received-Bytes: 2747 X-Received-Body-CRC: 1603035766 Xref: news.eternal-september.org comp.lang.ada:21516 Date: 2014-08-07T12:07:15-07:00 List-Id: 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