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,WEIRD_PORT autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,b672743914db49f X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!news2.google.com!news.glorb.com!wns13feed!worldnet.att.net!attbi_s21.POSTED!53ab2750!not-for-mail From: "Jeffrey R. Carter" User-Agent: Thunderbird 2.0.0.6 (Windows/20070728) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: "Ada Gems": Constructor functions References: <1189015827.384331.17490@k79g2000hse.googlegroups.com> In-Reply-To: <1189015827.384331.17490@k79g2000hse.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 8bit Message-ID: NNTP-Posting-Host: 12.201.97.213 X-Complaints-To: abuse@mchsi.com X-Trace: attbi_s21 1189032438 12.201.97.213 (Wed, 05 Sep 2007 22:47:18 GMT) NNTP-Posting-Date: Wed, 05 Sep 2007 22:47:18 GMT Organization: AT&T ASP.att.net Date: Wed, 05 Sep 2007 22:47:18 GMT Xref: g2news2.google.com comp.lang.ada:1765 Date: 2007-09-05T22:47:18+00:00 List-Id: Tomek Wa�kuski wrote: > > with Ada.Strings.Unbounded; > use Ada.Strings.Unbounded; > > package T is > type Object (<>) is tagged limited private; > > function Create_Object (Name : in String) return Object; > function Construct return Object; > function Name (This : in Object) return String; > > type Object is tagged limited > record > Name : Unbounded_String; > end record; > end T; T has a private type (Object) but no private part. > package body T is > function Create_Object (Name : in String) return Object is > return (Name => To_Unbounded_String (Name)); > end Create_Object; > > function Construct return Object is > return Create_Object (Name => "Object without a name!"); > end Construct; > > function Name (This : in Object) return String is > begin > return To_String (This.Name); > end Name; > > type Object is tagged limited > record > Name : Unbounded_String; > end record; > end T; Type Object is repeated here. > with T; > > procedure Test_T is > Some_Object : constant T.Object := Construct; > begin > null; > end Test_T; Construct is not directly visible here. > Is it REALLY a compiler bug? Or am I only dumb? :) Maybe I'm doing > something, somewhere wrong? It's really a compiler error. A compiler should be able to handle the errors in your code without crashing. FWIW, I got this with another version: gnatmake -O2 -gnaton -fstack-check test_t.adb gcc -c -O2 -gnaton -fstack-check test_t.adb test_t.adb:4:39: "Construct" is not visible test_t.adb:4:39: non-visible declaration at t.ads:8 t.ads:11:04: declaration of full view must appear in private part gnatmake: "test_t.adb" compilation error -- Jeff Carter "Death awaits you all, with nasty, big, pointy teeth!" Monty Python & the Holy Grail 20