comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: limited allocated classwide types
Date: Thu, 03 Nov 2011 23:14:30 +0000
Date: 2011-11-03T23:14:30+00:00	[thread overview]
Message-ID: <m21utoer3d.fsf@pushface.org> (raw)
In-Reply-To: 0ed43f83-40e7-46d3-8cc4-e1c41f500d28@c1g2000vbw.googlegroups.com

Simon Belmont <sbelmont700@gmail.com> writes:

> The entire sample program is at the bottom, but here is the basic
> jist:
>
[...]
> When the access type is changed to:
>
> type Foo_Ptr is access all I.LI'Class;
>
> the output crashes to some strange function that indicates it should
> be impossible to ever get to (hence my confusion):
>
> Entered Create
> Entered Initialize
> Entered Extended Return
> Leaving Extended Return
> Starting...
> Entered Finalize
>
> raised PROGRAM_ERROR : s-finroo.adb:42 explicit raise
> [2011-11-03 17:40:27] process exited with status 1 (elapsed time:
> 00.13s)

I added another procedure to LI:

   package I is
      type LI is limited interface;
      procedure Dummy (This : LI) is abstract;
      procedure Doo (This : LI) is abstract;
   end I;

and added the expected implementation, and then the output was

Entered Create
Entered Initialize
Entered Extended Return
Leaving Extended Return
Starting...
Entered Finalize               <-------------- !!!!
Ending...
Entered Finalize

but if I write

   package I is
      type LI is limited interface;
      procedure Doo (This : LI) is abstract;
      procedure Dummy (This : LI) is abstract;
   end I;

I get the Program_Error as before.

The reason it's possible to end up at Adjust in s-finroo.adb is that
System.Finalization_Root is common to Limited_Controlled and Controlled,
it's just that Limited_Controlled should of course never call it.

Looks as though the compiler has managed to mangle the dispatch table,
which is clearly a compiler error.

GCC 4.6, with your original code, outputs

Entered Create
Entered Initialize
Entered Extended Return
Leaving Extended Return
Starting...
Entered Initialize
Ending...

which is differently wrong, and GCC 4.7 (into which AdaCore have been
rolling changes to finalization like those in GNAT GPL 2011) behaves
like GNAT GPL 2011.




  parent reply	other threads:[~2011-11-03 23:14 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-03 22:01 limited allocated classwide types Simon Belmont
2011-11-03 22:50 ` Adam Beneschan
2011-11-03 23:14 ` Simon Wright [this message]
2011-11-03 23:35   ` Simon Belmont
2011-11-04  0:30     ` Adam Beneschan
2011-11-04  0:51       ` Adam Beneschan
2011-11-04  7:40     ` Simon Wright
2011-11-04  8:42       ` Dmitry A. Kazakov
2011-11-04  9:18     ` Georg Bauhaus
2011-11-04  9:53     ` Brian Drummond
2011-11-04 16:39       ` Simon Wright
2011-11-04 18:47       ` Adam Beneschan
2011-11-04 20:03         ` Simon Wright
2011-11-08  4:25         ` Randy Brukardt
2011-11-08 12:10           ` Brian Drummond
2011-11-08 12:35             ` Simon Wright
2011-11-08 13:05               ` Dmitry A. Kazakov
2011-11-10  9:56             ` Álex R. Mosteo
2011-11-04 12:25 ` Stephen Leake
replies disabled

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