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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,5d4ade2fd8fd67c6 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!news-out.readnews.com!transit3.readnews.com!panix!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Legit Warnings or not Date: Thu, 21 Jul 2011 11:13:01 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <531193e0-3305-4292-9ed8-0176226c1d00@x12g2000yql.googlegroups.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls6.std.com 1311261182 22146 192.74.137.71 (21 Jul 2011 15:13:02 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Thu, 21 Jul 2011 15:13:02 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:XowjkgHqxRhwNoZsHdG1s6WI+QQ= Xref: g2news1.google.com comp.lang.ada:20271 Date: 2011-07-21T11:13:01-04:00 List-Id: Jeffrey Carter writes: > There are 2 ways to handle such unconstrained objects. The easy way, > which GNAT uses, is to allocate enough space for the largest > variant. The harder way only allocates enough space for the current > value, and actually changes the space of the object if the size is > changed through an assignment. Right. I know of two Ada compilers that used this "deallocate-and-reallocate" method to change the size. One of them got it wrong. I don't remember the details, but I think it had to do with renaming a subcomponent, and then an assignment to the whole record caused the renaming to become a dangling pointer. The other compiler, as far as I know, got it right. > Some who have gone to the trouble to implement the 2nd way say they > think it was the intention of the language designers. Could be -- I don't know. I think for a low-level language like Ada, it's probably not a good idea to introduce implicit heap allocation. I'd at least want a way to turn it off. Implicit heap allocation could be a good feature in a different language, but then I'd want that language to allow: type Tree is tagged record Left, Right : Tree'Class; -- doubly illegal! end record; - Bob