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.107.175.25 with SMTP id y25mr2223183ioe.16.1522543957752; Sat, 31 Mar 2018 17:52:37 -0700 (PDT) X-Received: by 2002:a9d:bc8:: with SMTP id 66-v6mr226585oth.10.1522543957673; Sat, 31 Mar 2018 17:52:37 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!paganini.bofh.team!weretis.net!feeder6.news.weretis.net!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!k65-v6no750884ita.0!news-out.google.com!u64-v6ni3234itb.0!nntp.google.com!k65-v6no750882ita.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sat, 31 Mar 2018 17:52:37 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=173.71.218.250; posting-account=QF6XPQoAAABce2NyPxxDAaKdAkN6RgAf NNTP-Posting-Host: 173.71.218.250 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: limited agregate and limited components default initialization From: Jere Injection-Date: Sun, 01 Apr 2018 00:52:37 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader02.eternal-september.org comp.lang.ada:51264 Date: 2018-03-31T17:52:37-07:00 List-Id: On Saturday, March 31, 2018 at 7:36:59 PM UTC-4, Jean-Claude Rostaing wrote: > Why does a component declaration like that: > type Item_Accessor (Item: not null access Item_type) is limited record > Ref: Item_access := SET(Item_Record'(Item => ITEM.all, others => <>)); > end record; > unconstrained subtype in component declaration > ? ITEM is limited but IS constrained by the default initialisation > It forced me to add the function DEFAULT_INITIALIZATION as a parameter, which I would prefer to not to. But since the result is the same, I'll drop it. > Item (and the article it is in) is never meant to be left uninitialized. > > Also, how to get rid of the problem with > function Set (Value: in Item_type) return Smart_Pointers is > (Smart_Pointers'(Controlled with Node => new Accessor_type'(Data => new Item_type'(Value), Count => 1))); > which gives :Initialization not allowed for limited types. > So an aggregate like this is not counted as a "limited agregate" ?? I may be misunderstanding you, but if Item is a limited type with a default discriminant, it is "unconstrained" since the ada compiler cannot know at compile time what the actual size will be. See: https://gcc.gnu.org/onlinedocs/gnat_rm/The-Size-of-Discriminated-Records-with-Default-Discriminants.html