https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113350
Bug ID: 113350
Summary: Class wide renaming primitive.
Product: gcc
Version: 13.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: ada
Assignee: unassigned at gcc dot gnu.org
Reporter: p.p11 at orange dot fr
CC: dkm at gcc dot gnu.org
Target Milestone: ---
Created attachment 57049
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57049&action=edit
Reproducer.
Let's define:
package Loggings is
type Logging is tagged record
Output : Ada.Text_IO.File_Access;
end record;
procedure Log (Handler : Logging; Msg : String);
procedure Log (Handler : Logging; Msg : String; Err : Natural);
type Full_Logging is new Logging with null record;
procedure Log (Handler : Full_Logging; Msg : String);
end Loggings;
and declare:
My_Handler : aliased Loggings.Logging := (Output =>
Ada.Text_IO.Current_Output);
My_Full_Handler : aliased Loggings.Full_Logging := (Output =>
Ada.Text_IO.Current_Output);
My_Generic_Handler : access Loggings.Logging'Class := My_Handler'Access;
procedure My_Log_3 (Msg : String) renames My_Generic_Handler.Log;
and code:
My_Log_3 ("Hei");
My_Generic_Handler := My_Full_Handler'Access;
My_Log_3 ("Hei");
and result with GNAT 13.2.0:
Hei
Full Hei
Expected result:
Hei
Hei
Discussion from Randy on CLA
(https://groups.google.com/g/comp.lang.ada/c/wpjZmaqmLrk):
The "name" is evaluated during a renaming, and the renamed entity does not
change afterwards. So whatever subprogram My_Log_3 designates for the first
call should be the same for the second call.