From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Limited initialization for non-limited types
Date: Wed, 26 Mar 2008 10:02:46 -0400
Date: 2008-03-26T10:02:46-04:00 [thread overview]
Message-ID: <wcc7ifpmvll.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: b481036a-41ee-4fc5-a0d0-c73cfef60234@s19g2000prg.googlegroups.com
Eric Hughes <eric.eh9@gmail.com> writes:
> Is there any way of getting in-place initialization for non-limited
> objects?
No.
We're thinking about doing that in GNAT as an optimization,
but there's no way to force it. Note that assignment
statements cannot use build-in-place in all cases.
Perhaps you can get what you want by wrapping a nonlimited type in a
limited record?
> So here's the problem. I can't trace the Initialize call
> "correctly". Consider the obvious initialization:
>
> T : Trace ;
> A : X := Construct_X( T ) ;
>
> Because X is not a limited type, this code translates thus (in one
> ordering):
>
> T : Trace ;
> A : X ;
> Initialize( A ) ;
> Temp : X := Construct_X( T ) ; -- as if limited, constructed in
> place
> Initialize( Temp ) ; -- (*)
> Finalize( A ) ;
> A := Temp ;
> Adjust( A ) ;
> Finalize( Temp ) ;
That's not a correct translation. For example, the line marked (*) will
overwrite the result of Construct_X.
To see what GNAT actually generates, use the -gnatD or -gnatG switch.
But there's no guarantee it won't change in future versions!
- Bob
next prev parent reply other threads:[~2008-03-26 14:02 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-26 13:26 Limited initialization for non-limited types Eric Hughes
2008-03-26 14:02 ` Robert A Duff [this message]
2008-03-27 0:07 ` Eric Hughes
2008-03-26 15:08 ` Dmitry A. Kazakov
2008-03-26 22:13 ` Randy Brukardt
2008-03-27 3:25 ` Eric Hughes
2008-03-28 6:56 ` Randy Brukardt
2008-03-28 15:25 ` Eric Hughes
2008-03-28 21:53 ` Randy Brukardt
2008-03-28 23:37 ` Eric Hughes
2008-04-02 3:00 ` Eric Hughes
2008-03-26 23:00 ` Lucretia
2008-03-28 11:23 ` Martin Krischik
2008-03-28 15:47 ` Eric Hughes
2008-04-02 4:06 ` Eric Hughes
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox