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,a88e582de42cdc9b X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!feeder3.cambrium.nl!feeder1.cambrium.nl!feed.tweaknews.nl!138.195.8.3.MISMATCH!news.ecp.fr!news.jacob-sparre.dk!pnx.dk!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Bug in Ada (SuSe 10.2) ? Date: Wed, 27 Feb 2008 18:30:34 -0600 Organization: Jacob's private Usenet server Message-ID: References: <0_mdna0iHpIsCifaRVnzvQA@telenor.com> <3a281192-2744-4110-9fc1-90c155c9436b@d4g2000prg.googlegroups.com> <48277611-402f-4622-be05-6edddf6dd56a@o10g2000hsf.googlegroups.com> <624tcvF21i3nvU1@mid.individual.net> <2630d99b-1578-4d79-ac9c-64c00c203b77@e60g2000hsh.googlegroups.com> <69019a65-736e-48ee-bd9f-4c29cd7fc88f@72g2000hsu.googlegroups.com> <48a0a0c4-7b79-42dc-b541-7a68693bdd4c@e41g2000hsc.googlegroups.com> <626c2f0a-d308-437d-888e-0f3ced336f01@f47g2000hsd.googlegroups.com> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: jacob-sparre.dk 1204158670 31270 69.95.181.76 (28 Feb 2008 00:31:10 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Thu, 28 Feb 2008 00:31:10 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1914 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1914 Xref: g2news1.google.com comp.lang.ada:20136 Date: 2008-02-27T18:30:34-06:00 List-Id: "Robert A Duff" wrote in message news:wcc7igq2ssj.fsf@shell01.TheWorld.com... > billjones6789@yahoo.com writes: ... > > Yes, here's another copy. Randy reports a compile-time > > error message, and Bob Klungle reports that the program > > runs without raising program_error. > > Ah, thanks for reposting that. > > Unless I'm missing something, both compiler behaviors are bugs, > and should be reported. I would expect a run-time error in WoW, > and there's no compiler switch that's supposed to turn this > check on -- it's supposed to be on by default. Why do you think a compile-time message is a bug? I've convinced myself that it is correct. Look at the body of WoW closely: function WoW (Slats: access AirSpeed) return Int_Access is begin return Slats.Altitude'Access; end WoW; Since Slats is an access value, this is really a dereference. That is, the return statement really is: return Slats.all.Altitude'Access; And you lose the special (dynamic) accessibility with the dereference. Thus, you get a static check (which fails in this case). Randy. > > with Ada.Text_IO; > > procedure Dangling_Pointer2 is > > type Int_Access is access all integer; > > > > Save : Int_Access; > > > > type AirSpeed is record > > Altitude : aliased integer := 9; > > end record; > > > > function WoW (Slats: access AirSpeed) return Int_Access is > > begin > > return Slats.Altitude'Access; > > end WoW; > > > > procedure Calculate is > > Heading : aliased AirSpeed; > > begin > > Save := WoW (Heading'access); > > Ada.Text_IO.Put_Line (integer'image(Save.all)); > > end Calculate; > > > > procedure Mess_with_stack is > > Dummy: array(1..10) of integer := (others => 17); > > begin > > null; > > end Mess_with_stack; > > > > begin > > Calculate; > > Mess_with_stack; > > Ada.Text_IO.Put_Line (integer'image(Save.all)); > > end Dangling_Pointer2; > > - Bob