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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,68536605ede13a20,start X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.189.194 with SMTP id gk2mr12373648pbc.3.1324149441288; Sat, 17 Dec 2011 11:17:21 -0800 (PST) Path: lh20ni33922pbb.0!nntp.google.com!news1.google.com!postnews.google.com!n10g2000vbg.googlegroups.com!not-for-mail From: Simon Belmont Newsgroups: comp.lang.ada Subject: GNAT - return by anonymous access Date: Sat, 17 Dec 2011 11:17:20 -0800 (PST) Organization: http://groups.google.com Message-ID: <784c67eb-a542-41b0-b23d-fca1234e56b2@n10g2000vbg.googlegroups.com> NNTP-Posting-Host: 24.218.138.255 Mime-Version: 1.0 X-Trace: posting.google.com 1324149441 19095 127.0.0.1 (17 Dec 2011 19:17:21 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 17 Dec 2011 19:17:21 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: n10g2000vbg.googlegroups.com; posting-host=24.218.138.255; posting-account=ShYTIAoAAABytvcS76ZrG9GdaV-nXYKy User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: ARLUEHNKC X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; InfoPath.2),gzip(gfe) Content-Type: text/plain; charset=ISO-8859-1 Date: 2011-12-17T11:17:20-08:00 List-Id: This ostensibly simple program prints strange results, and i'm rapidly losing faith in the GNAT compiler (GNAT GPL 20110428). If anyone with an alternative compiler can confirm or deny this output as spurious, I would be much obliged. In short, when the declaration of 'bar' is commented out, the program behaves as i would expect (output is '42'), but when bar is present, the output is much different (output is '4409264'). Or, if my line of reasoning is mixed up and this is actually the appropriate behavior, I would be grateful for any explanation. Thank you again -sb -- Unit 1 package test_package is type test_type (p_obj : access Integer) is limited private; function get return test_type; private type test_type (p_obj : access Integer) is limited null record; end test_package; -- Unit 2 package body test_package is function get return test_type is begin return test_type'(p_obj => new Integer'(42)); end get; end test_package; -- Unit 3 with test_package; with Text_IO; procedure test_driver is foo : test_package.test_type := test_package.get; -- Removed : '42' (expected) -- Present : '4409264' bar : access Integer := new Integer'(69); begin Text_IO.Put_Line(foo.p_obj.all'img); end test_driver;