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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.43.38.67 with SMTP id th3mr2321421icb.34.1413049555459; Sat, 11 Oct 2014 10:45:55 -0700 (PDT) X-Received: by 10.140.37.39 with SMTP id q36mr3409qgq.10.1413049555325; Sat, 11 Oct 2014 10:45:55 -0700 (PDT) Path: border2.nntp.dca1.giganews.com!nntp.giganews.com!news.glorb.com!h18no4716302igc.0!news-out.google.com!i10ni82qaf.0!nntp.google.com!dc16no2134174qab.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sat, 11 Oct 2014 10:45:55 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=206.53.78.59; posting-account=ShYTIAoAAABytvcS76ZrG9GdaV-nXYKy NNTP-Posting-Host: 206.53.78.59 References: <8d6fe2a6-a8fa-441f-8b35-fc5a744359fb@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Type extension and discriminants From: sbelmont700@gmail.com Injection-Date: Sat, 11 Oct 2014 17:45:55 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: number.nntp.giganews.com comp.lang.ada:189654 Date: 2014-10-11T10:45:55-07:00 List-Id: On Friday, October 10, 2014 6:34:54 PM UTC-4, Randy Brukardt wrote: > It would have helped a bit had you given an example. Thank you for your response. An example follows: package A is type T1 (<>) is tagged limited private; function T1_Ctor return T1; private type T1 (I_Ptr : access Integer) is tagged limited null record; end A; package body A is function T1_Ctor return T1 is begin return (I_Ptr =3D> null); end T1_Ctor; end A; with A; package B is type T2 (<>) is new A.T1 with private; function T2_Ctor return T2; private type T2 is new A.T1 with null record; end B; package body B is function T2_Ctor return T2 is begin return T2'(A.T1_Ctor with null record); end T2_Ctor; =20 end B; This code as written makes GNAT go Blammo when compiling b.adb {GPL 2014 (2= 0140331) (i686-pc-mingw32) GCC error: in gnat_to_gnu_entity, at ada/gcc-int= erface/decl.c:289 | Error detected at b.ads:11:8}, so clearly there is a bu= g in there somewhere, but more often than not crashes come from parsing bad= code on my end, so I just assume it's me. Then when playing around I real= ized that it would accept T2 without the explicit (<>), and was doubtful as= to whether it had to be there (I prefer it as well), or if it was just imp= licitly declared from T1 (like 'limited'), which was followed by my realiza= tion that I didn't even know if this should be valid to begin with. Moreover, changing T1 from an access discriminant (e.g. just 'Integer' inst= ead of 'access Integer'), makes it compile fine, but removing all the discr= iminants from T1 (but leaving it unknown in the public part) causes an odd = compiler error (uninitialized unconstrained allocation not allowed / qualif= ied expression required) on the full type declaration of T2, which seems li= ke at least the wrong error message, if not an error itself (it would seem = just as legal to have no discriminants as access or named ones). Making T1 fully public fixes everything. The stated approach seems legal, at least in concept, but the variety of cr= ashes and errors made me suspect. I will be submitting this as a bug repor= t at the very least for the hard crash, and probably for the error messages= as well. Thank you again for your continued helpful responses. -sb