This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug ada/62042] New: Missing optimization of copying non-limited objects
- From: "porton at narod dot ru" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 06 Aug 2014 20:36:06 +0000
- Subject: [Bug ada/62042] New: Missing optimization of copying non-limited objects
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62042
Bug ID: 62042
Summary: Missing optimization of copying non-limited objects
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: ada
Assignee: unassigned at gcc dot gnu.org
Reporter: porton at narod dot ru
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. 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;