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.66.65.75 with SMTP id v11mr4645374pas.7.1439882679939; Tue, 18 Aug 2015 00:24:39 -0700 (PDT) X-Received: by 10.140.28.10 with SMTP id 10mr62313qgy.26.1439882679889; Tue, 18 Aug 2015 00:24:39 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!news.glorb.com!se8no5766952igc.0!news-out.google.com!b31ni8265qge.0!nntp.google.com!y105no1296542qge.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 18 Aug 2015 00:24:39 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=193.71.180.114; posting-account=uulyKwoAAAA86DO0ODu--rZtbje8Sytn NNTP-Posting-Host: 193.71.180.114 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: storage error: stack overflow From: Egil H H Injection-Date: Tue, 18 Aug 2015 07:24:39 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: news.eternal-september.org comp.lang.ada:27485 Date: 2015-08-18T00:24:39-07:00 List-Id: On Tuesday, August 18, 2015 at 4:16:38 AM UTC+2, hreba wrote: > > with Ada.Strings.Unbounded; > > procedure testUBS is > > type TA is record > name: Ada.Strings.Unbounded.Unbounded_String; > end record; > > type TB is record > a: TA; > end record; > > function New_TB (name: String:="") return access TB is > begin > return new TB' > (a=>TA'(name=>Ada.Strings.Unbounded.To_Unbounded_String(name))); > end New_TB; > > b: access TB:= New_TB (name=>"Det"); > name: Ada.Strings.Unbounded.Unbounded_String; > > begin > name:= b.a.name; > end testUBS; > This fails as described with Gnat Pro 6.4.1 (GCC 4.5.2), but seems to be fixed in later versions, at least Gnat Pro 7.1.1 (GCC 4.7.3). You should try to avoid anonymous access types if at all possible. However, you could try to work around the problem using an extended return, like this: function New_TB (Name : String := "") return access TB is begin return Foo : access TB := new TB do foo.all := TB' (A => TA' (Name => Ada.Strings.Unbounded.To_Unbounded_String(Name))); end return; end New_TB;