comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: Potential Coextension Bug in GNAT
Date: Thu, 20 Dec 2018 17:58:11 +0000
Date: 2018-12-20T17:58:11+00:00	[thread overview]
Message-ID: <lya7l0dqrw.fsf@pushface.org> (raw)
In-Reply-To: f8aca7a2-3b3a-4934-8219-c2961dc79458@googlegroups.com

Jere <jhb.chat@gmail.com> writes:

> with Ada.Text_IO; use Ada.Text_IO;
> with Ada.Finalization; use Ada.Finalization;
>
> procedure Hello is
>
>     type Thing_1 is new Limited_Controlled with null record;
>     
>     overriding 
>     procedure Finalize(Self : in out Thing_1) is
>     begin
>         Put_Line("Finalize Thing_1");
>     end Finalize;
>     
>     type Thing_2
>         (Other : not null access Thing_1)
>     is limited null record;
>     
>     procedure Test_Coextension_1 is
>         The_Thing : Thing_2(new Thing_1);

This is a case of 14.1/3, an allocator used to define the discriminant
of an object,

>     begin
>         Put_Line("Coextenson directly initialized");
>     end Test_Coextension_1;
>     
>     function Make_Thing_2 return Thing_2 is
>     begin
>         return (Other => new Thing_1);

I think GNAT thinks this is a case of 14.2/3, an allocator used to
define the constraint in a subtype_indication, though I'm hard put to it
to see the difference from the first case.

>     end Make_Thing_2;
>     
>     procedure Test_Coextension_2 is
>         The_Thing : Thing_2 := Make_Thing_2;
>     begin
>         Put_Line("Coextension initialized through build in place");
>     end Test_Coextension_2;
>     
> begin
>     Test_Coextension_1;
>     Test_Coextension_2;
>     Put_Line("Test Finished");
> end Hello;


  parent reply	other threads:[~2018-12-20 17:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-20 15:59 Potential Coextension Bug in GNAT Jere
2018-12-20 16:02 ` Jere
2018-12-20 16:56 ` Simon Wright
2018-12-21  2:16   ` Randy Brukardt
2018-12-21 11:24   ` Jere
2018-12-20 17:58 ` Simon Wright [this message]
2018-12-21  2:25   ` Randy Brukardt
2018-12-21 11:32     ` Jere
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox