The object renaming does not behave properly as demonstrated with the test codes below. Note that line 11 of message_services.adb contains the problem. In addition, if line 11 is commented out and line 12 in uncommented, the codes behave properly. package Message_Services is type Message_Code is range 0 .. 100; subtype Message is String; function Get_Message (Code : Message_Code) return String; pragma Inline (Get_Message); end Message_Services; package body Message_Services is type Message_Handle is access constant Message; Message_0 : aliased constant Message := "OK"; Message_1 : aliased constant Message := "Up"; Message_2 : aliased constant Message := "Down"; Message_3 : aliased constant Message := "Left"; Message_4 : aliased constant Message := "Right"; -- ... Default : Message renames Message_0; -- bug here -- Default : aliased constant Message := Message_0; -- work around Message_Table : array (Message_Code) of Message_Handle := ( 000 => Message_0'access, 001 => Message_1'access, 002 => Message_2'access, 003 => Message_3'access, 004 => Message_4'access, others => Default'access); function Get_Message (Code : Message_Code) return String is begin return Message_Table (Code).all; end Get_Message; end Message_Services; with Ada.Text_IO; procedure Message_Services.Test is use Ada; use Text_IO; Test_Message : constant Message := "OK"; begin Put_Line ("Static Ragged Array construction, no heap involvement"); for Index in Message_Code range 0 .. 9 loop Put_Line ("Message" & Message_Code'Image (Index) & " is: " & Get_Message (Index)); end loop; for Index in Message_Code range 5 .. 9 loop if Get_Message (Index) /= Test_Message then Put_Line ("Test fails"); return; end if; end loop; Put_Line ("Test passes"); end Message_Services.Test;
Sorry for the typo in problem description paragraph. What I mean was if line 11 commented out and line 12 uncommented, the codes behave properly.
This problem does not occur in gcc-4.3-20080118.
What compilation option did you use? I cannot reproduce this with Debian's 4.3 compiler or with current SVN trunk.
Sam, If you look at my comment on 21 January 2008. This problem was fixed starting with gcc-4.3-20080118. That is why you did not see the problem existed. In summary, this PR should be closed around that time.
Indeed, I missed the "not" in your message :) This is great news. Closing.