From: "A. Cervetti" <andrea.cervetti@gmail.com>
Subject: Re: Alleged GNAT bug
Date: Tue, 24 Oct 2017 03:13:53 -0700 (PDT)
Date: 2017-10-24T03:13:53-07:00 [thread overview]
Message-ID: <2be64a8b-5f89-414c-9dcd-433bd5d855a0@googlegroups.com> (raw)
In-Reply-To: <osde6h$256$1@gioia.aioe.org>
>
> I state that a legal program fails with a compiler error message.
>
> But please confirm if my program (see above URL) is really legal. Maybe I
> mistake?
No, it is not.
The reason is not obvious and a little convoluted (like your program too) and depend upon the freezing rules (arm 13.14)
Anyway the reference to System.ads in the error message is misleading.
In the generic package With_Finalization you derive the type Derived from the formal Base type. Derived is a record extension (although null) of the base type.
This means that, when you instantiate the package the actual Term_Type_Without_Finalize is frozen (13.14.7).
The compiler tries to create a dispatch table for the primitive operation of the type.
Get_Literal is a primitive operation so it is frozen too (13.14.15 1/3) but the return type Term_Literal_Value is still incomplete (7.3.5)
The ARM is not explicit about this (as far as I know, any language lawyer out there?) but the reason of the error is as I said.
To avoid the error you should instantiate the package Finalizer after the completion of Term_Literal_Value.
if you need visibility of Term_Type you can declare it as private too.
....
type Term_Type is private;
private
type Term_Literal_Value is null record;
package Finalizer is new Term_Handled_Record.With_Finalization(Term_Type_Without_Finalize);
type Term_Type is new Finalizer.Derived with null record;
....
This works.
A.
next prev parent reply other threads:[~2017-10-24 10:13 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-20 18:10 Alleged GNAT bug Victor Porton
2017-10-24 10:13 ` A. Cervetti [this message]
2017-10-24 23:08 ` Randy Brukardt
2017-10-25 0:53 ` A. Cervetti
2017-10-25 17:03 ` AdaMagica
2017-10-25 17:27 ` Victor Porton
2017-10-26 7:09 ` AdaMagica
2017-10-26 18:41 ` Victor Porton
2017-11-14 23:35 ` Randy Brukardt
2017-11-16 15:55 ` Robert Eachus
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox