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 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Potential Coextension Bug in GNAT Date: Thu, 20 Dec 2018 17:58:11 +0000 Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader01.eternal-september.org; posting-host="631a6c6f0697ed88e2921e868fe3a3bd"; logging-data="10099"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18mKNx2BV/4Na506VzHLhfguHLQt1wk3bE=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (darwin) Cancel-Lock: sha1:VFvSurRAfp5e6b6XQa7MYtsJgmE= sha1:cg75Z5PPcH2qBg1CW6QVWoCc668= Xref: reader01.eternal-september.org comp.lang.ada:55087 Date: 2018-12-20T17:58:11+00:00 List-Id: Jere 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;