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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!news.glorb.com!Xl.tags.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail NNTP-Posting-Date: Wed, 06 Apr 2016 06:44:08 -0500 From: Dennis Lee Bieber Newsgroups: comp.lang.ada Subject: Re: Uninitialized out parameters. Date: Wed, 06 Apr 2016 07:44:11 -0400 Organization: IISS Elusive Unicorn Message-ID: References: <3be79ab3-ebc7-4169-9713-d50349662403@googlegroups.com> <70a76f87-51a9-4e77-9fa0-79714f9c0ba7@googlegroups.com> X-Newsreader: Forte Agent 6.00/32.1186 X-No-Archive: YES MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 108.68.178.90 X-Trace: sv3-OTsuf0ZnMc0UhS53u7CS2u5pFaS6QdaP6OgoK537lGJUu8lhyOoCwePYxub8AUg2NIx7HykcCM2Ny1C!REl51ze/S5a2ZS5lYedETTbo8a4bAyRTbgpTW9pgEHcO/whEy0WnNE6GhEsQk1QTmKmFoJHypu+b!Aw3a7xUHSV0v21aVgJo0RRSU7Ys= X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 2985 Xref: news.eternal-september.org comp.lang.ada:30008 Date: 2016-04-06T07:44:11-04:00 List-Id: On Wed, 6 Apr 2016 12:17:05 +0200, "G.B." declaimed the following: >On 06.04.16 10:19, ahlan@marriott.org wrote: >> On Tuesday, April 5, 2016 at 6:19:47 PM UTC+2, G.B. wrote: >>> On 05.04.16 14:02, ahlan@marriott.org wrote: >>>> Ada.Text_IO.Put_Line ("V:" & V'img); >>>> >>>> The value zero is output, which because V is positive should be impossible. >>> >>> Addressing just this issue: the line is calling >>> implementation defined attribute 'IMG, which can >>> do as it pleases. The Ada type attribute 'Image >>> takes a value of type Positive'Base, which includes 0, >>> which is why outputting 0 is perfectly fine. >>> >>> (It's not a subtype attribute, but a type attribute, >>> if this makes sense.) >> >> The issue here is not whether or not 'img fails but the fact that V is returned with a value out of range. > >The issue is rather, I think, whether V is returned at all. >There would have to be an assignment within the null procedure. > Which could be a case if the compiler used copy-in/copy-out semantics for scalars (or just copy-out for the test sample). GNAT, if I recall, uses reference semantics, and as out-only wouldn't be checking the initial value on entry. I'd concur that V is not being returned -- it retains whatever value the uninitialized memory space held on entry. If one must guard, then http://www.adaic.org/resources/add_content/standards/05aarm/html/AA-13-9-2.html may be applicable """ 4 20 Invalid data can be created in the following cases (not counting erroneous or unpredictable execution): 5 an uninitialized scalar object, """ -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/