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!feeder.news-service.com!newsfeed.straub-nv.de!weretis.net!feeder4.news.weretis.net!news.tornevall.net!.POSTED!not-for-mail From: Jeffrey Carter Newsgroups: comp.lang.ada Subject: Re: Legit Warnings or not Date: Wed, 20 Jul 2011 19:37:48 -0700 Organization: TornevallNET - http://news.tornevall.net Message-ID: References: <531193e0-3305-4292-9ed8-0176226c1d00@x12g2000yql.googlegroups.com> NNTP-Posting-Host: e65ed81541600b63ce78911d46f10396 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: aabeb84b6c7b86b16ad7ac3d8dae5339 X-Complaints-To: abuse@tornevall.net User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.18) Gecko/20110617 Thunderbird/3.1.11 X-Complaints-Language: Spoken language is english or swedish - NOT ITALIAN, FRENCH, GERMAN OR ANY OTHER LANGUAGE! In-Reply-To: <531193e0-3305-4292-9ed8-0176226c1d00@x12g2000yql.googlegroups.com> X-UserIDNumber: 1738 X-Validate-Post: http://news.tornevall.net/validate.php?trace=aabeb84b6c7b86b16ad7ac3d8dae5339 X-Complaints-Italiano: Non abbiamo padronanza della lingua italiana - se mandate una email scrivete solo in Inglese, grazie X-Posting-User: 0243687135df8c4b260dd4a9a93c79bd Xref: g2news2.google.com comp.lang.ada:21224 Date: 2011-07-20T19:37:48-07:00 List-Id: On 07/20/2011 03:30 PM, Anh Vo wrote: > package Warnings_Legit is > > type Warned_Person (Size : Positive := 10) is -- Warnings issued > here > record > Name : String (1 .. Size); > end record; > > type Acceptable_Person (Size : Positive) is > record > Name : String (1 .. Size); > end record; > > end Warnings_Legit; > > 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. > > Is this warnings legitimate? If yes, why line 8 is OK. Otherwise, > should it be a bug? Duff has given you a good answer as to why GNAT has that warning. What he didn't say is that some compilers not only won't give any warning, but a declaration of X : Warned_Person; will not raise Storage_Error on those compilers, either. 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. Some who have gone to the trouble to implement the 2nd way say they think it was the intention of the language designers. -- Jeff Carter "He didn't get that nose from playing ping-pong." Never Give a Sucker an Even Break 110