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,c022fc5445abd13d,start X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!irazu.switch.ch!news-zh.switch.ch!switch.ch!cernne03.cern.ch!cern.ch!news From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: Discriminated types with default discriminants Date: Thu, 03 Nov 2005 16:50:12 +0100 Organization: CERN - European Laboratory for Particle Physics Message-ID: NNTP-Posting-Host: abpc10883.cern.ch Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sunnews.cern.ch 1131033012 12712 (None) 137.138.37.241 X-Complaints-To: news@sunnews.cern.ch User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050922 Red Hat/1.7.12-1.1.3.2.SL3 X-Accept-Language: en-us, en Xref: g2news1.google.com comp.lang.ada:6147 Date: 2005-11-03T16:50:12+01:00 List-Id: Hi, Consider this: procedure Hello is type Discriminated(Size : Integer := 10) is record Value : String (1..Size); end record; S : Discriminated; begin null; end Hello; Compiler (GNAT) gives me two warnings: 5. Value : String (1..Size); | >>> warning: creation of object of this type may raise Storage_Error 8. S : Discriminated; | >>> warning: Storage_Error will be raised at run-time Moreover, it keeps a promise and indeed the program raises STORAGE_ERROR at run-time. What's happening here? Why the object S is not created with 10 as the default discriminant? I can get rid of the second warning by declaring S as: S : Discriminated(10); Indeed - program runs fine (i.e. it does not raise any exception). What's the difference? I can get rid of the first warning with this: subtype MyInt is Integer; type Discriminated(Size : MyInt := 10) is -- ... What's the difference? -- Maciej Sobczak : http://www.msobczak.com/ Programming : http://www.msobczak.com/prog/