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: g2news2.google.com!news3.google.com!proxad.net!feeder1-2.proxad.net!news.in2p3.fr!in2p3.fr!news.ecp.fr!news.jacob-sparre.dk!pnx.dk!jacob-sparre.dk!ada-dk.org!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Legit Warnings or not Date: Fri, 22 Jul 2011 19:26:59 -0500 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: <531193e0-3305-4292-9ed8-0176226c1d00@x12g2000yql.googlegroups.com> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1311380821 25420 69.95.181.76 (23 Jul 2011 00:27:01 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Sat, 23 Jul 2011 00:27:01 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6109 Xref: g2news2.google.com comp.lang.ada:21277 Date: 2011-07-22T19:26:59-05:00 List-Id: "Robert A Duff" wrote in message news:wccy5zslezc.fsf@shell01.TheWorld.com... ... >> The code segment above triggers a warnings message 'creation of >> "Warned_Person" object may raise Storage_Error' at line 3 as marked. >> However, no warnings is issued at line 8. The difference between them >> is default discriminant. I am using GNAT-GPL-2011. > > There's a confusing rule in Ada: If it has defaults, there can be > unconstrained objects of that type (and also constrained ones). > If it doesn't have defaults, then all objects must be constrained. > > So if you say "X : Warned_Person;", GNAT will allocate space for > billions of characters (not just 10) because you might assign > a bigger one (like "X := (Size => 1_000_000, Name => Something)"). Right, but I personally consider this a bug. The bug is in the Ada market (and ACATS) in that implementations that do this by default are allowed -- it's not a bug in the Ada standard or a bug with GNAT (this is commonly accepted -- by everyone other than me) behavior. >> Is this warnings legitimate? If yes, why line 8 is OK. Otherwise, >> should it be a bug? > > It's not a bug. An object of type Warned_Person might need huge amounts > of memory, so Storage_Error might well be raised. And that to me is a bug. It's not that hard to implement on-demand allocation if the object turns out to be huge. I understand the requirements to avoid secondary allocation and the like, and it makes perfect sense to me for this behavior to occur when certain restrictions are in place. But it doesn't make sense to me for this behavior to be the default. It makes Ada less useful than it otherwise would be, and often forces programmers to use access types when they otherwise would not need them. The fewer explicit access types in a program, the better!! Randy.