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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5117b1b6391a0e06 X-Google-Attributes: gid103376,public Path: g2news1.google.com!news1.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newshosting.com!nx01.iad01.newshosting.com!newsfeed.icl.net!newsfeed.fjserv.net!kibo.news.demon.net!news.demon.co.uk!demon!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: A simple ADA puzzle (I haven't the answer) Date: 16 Jun 2004 20:51:57 +0100 Organization: Pushface Sender: simon@smaug.pushface.org Message-ID: References: <4x_zc.40702$G%.32360@tornado.fastwebnet.it> NNTP-Posting-Host: pogner.demon.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: news.demon.co.uk 1087415808 612 62.49.19.209 (16 Jun 2004 19:56:48 GMT) X-Complaints-To: abuse@demon.net NNTP-Posting-Date: Wed, 16 Jun 2004 19:56:48 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 Xref: g2news1.google.com comp.lang.ada:1586 Date: 2004-06-16T20:51:57+01:00 List-Id: "Abby" writes: > Thanx for your answer. Sorry if I don't show you well what my > problem is, I try again ;) : I have the structure as in my first > post and I can't change it, I mean, "someone" wrote that type and I > must use it so i need to declare a variable of that "monstrous" type > and I can't change that type in anyway. DO you know some way to > declare and use it without any constraint error? Thanx again! I wrote this little subset: ------------------------------------------------------------------------ procedure Huge is type Len_Type is array (Integer range <>) of Character; type String_Type (Len : Integer := 0) is record String : Len_Type (1 .. Len); end record; X : String_Type (Len => 24); Y : String_Type; begin null; end Huge; ------------------------------------------------------------------------ and GNAT says: gcc -c -I/home/simon/tmp/ -g -gnatqQafoy -gnatwaL -O2 -I- /home/simon/tmp/huge.adb huge.adb:4:09: warning: creation of "String_Type" object may raise Storage_Error huge.adb:8:04: warning: "X" is never assigned a value huge.adb:9:04: warning: "Y" is never assigned a value huge.adb:9:04: warning: Storage_Error will be raised at run-time gnatbind -aO./ -E -I- -x huge.ali gnatlink huge.ali -o /home/simon/tmp/huge -g So there is no problem with my declaration of X, because I've constrained the object X. The warning at line 4 says that there may be a problem .. and sure enough the second warning at line 9 shows it's happened. I don't know if it's clear from what the other people have been saying, but the difficulty is that Y can change size at run time: so there has to be enough space reserved for it to expand into. All the above is fine at one level of record composition. I think the full set you supplied are past praying for .. -- Simon Wright 100% Ada, no bugs.