comp.lang.ada
 help / color / mirror / Atom feed
From: Victor Porton <porton@narod.ru>
Subject: Re: GNAT 4.9 - missing optimization feature?
Date: Wed, 06 Aug 2014 17:19:08 +0300
Date: 2014-08-06T17:19:08+03:00	[thread overview]
Message-ID: <lrtdgp$93q$1@speranza.aioe.org> (raw)
In-Reply-To: lrrnc5$kmk$1@speranza.aioe.org

Victor Porton wrote:

> The below program, compiled with GNAT 4.9, calls Adjust two times when
> copying a T1 object.
> 
> But it does the same operations with a T2 object without calling Adjust.
> 
> So calling Adjust on a T1 object is here redundant and can be optimized
> away for greater performance. If I recall correctly, Ada Reference Manual
> allows this kind of optimization.
> 
> So GNAT is not as good as I expected, isn't it?
> 
> with Ada.Finalization;
> with Ada.Text_IO;
> 
> procedure Main is
> 
>    type T1 is new Ada.Finalization.Controlled with null record;
>    type T2 is new Ada.Finalization.Limited_Controlled with null record;
>    
>    overriding procedure Adjust(Object: in out T1) is
>    begin
>       Ada.Text_IO.Put_Line("Adjust");
>    end;
> 
>    function F return T1 is
>    begin
>       return (Ada.Finalization.Controlled with null record);
>    end;
>    
>    function F return T2 is
>    begin
>       return (Ada.Finalization.Limited_Controlled with null record);
>    end;
>    
>    X: T1 := F;
>    Y: T2 := F;
> 
> begin
>    null;
> end;

Is it true that this kind of optimization is legitimate accordingly ARM?

-- 
Victor Porton - http://portonvictor.org

  reply	other threads:[~2014-08-06 14:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-05 22:55 GNAT 4.9 - missing optimization feature? Victor Porton
2014-08-06 14:19 ` Victor Porton [this message]
2014-08-06 15:10   ` J-P. Rosen
2014-08-06 15:16     ` Adam Beneschan
2014-08-06 15:35       ` J-P. Rosen
2014-08-06 15:44         ` Adam Beneschan
2014-08-06 15:15   ` Adam Beneschan
replies disabled

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