Look at the following example:
with System; use System;                      
with Ada.Text_Io; use Ada.Text_IO;

procedure foo is
   bar : constant integer := 1;
   foobar : integer renames bar;
begin
   if foo'Address = foobar'Address then
      Put_Line ("OK");
   end if;
end foo;

The normal output of this program would be OK, but in fact the test fails.
Another example:
package foo is
   bar : constant integer := 1;
   foobar : integer renames bar;
end foo;

$ gcc -c foo.ads
Two symbols are created:
$ nm foo.o
00000000 D foo__bar
00000001 C foo_E
00000004 D foo__foobar

Futhermore I checked and both symbols reserve space (there 4 bytes).
$ objdump -t foo.o
[...]
00000000 g     O .data  00000004 foo__bar
00000004 g     O .data  00000004 foo__foobar

Nevertheless both get the right value:
$ readelf -x 2 foo.o 

Hex dump of section '.data':
  0x00000000                   00000001 00000001 ........

If I declare a variable instead of a constant, then we get the normal behaviour 
(ie only 1 symbol and 1 space for it):
package Foo is

   Bar : Integer := 1;
   FooBar : Integer renames Bar;

end Foo;
$ gcc -c foo.ads
$ nm foo.o
00000000 D foo__bar
00000001 C foo_E

-- 
           Summary: constant renaming creates new constant
           Product: gcc
           Version: 3.4.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: ada
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jc at apinc dot org
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: i486-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19037

Reply via email to