[Bug c/54666] New: when do lto opitimizing with attribute (weak,alias), it will produce wrong code

hcj20080469 at 163 dot com gcc-bugzilla@gcc.gnu.org
Sat Sep 22 02:06:00 GMT 2012


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

             Bug #: 54666
           Summary: when do lto opitimizing with attribute (weak,alias),
                    it will produce wrong code
    Classification: Unclassified
           Product: gcc
           Version: lto
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: hcj20080469@163.com


gcc version is gcc4.7.1
host,build adn target is  x86 i586

test case name: weak_0.c

extern void abort(void);

int foo =0 ;

extern int bar __attribute__ ((weak,alias ("foo")));
int main(void)
{
/*      if( &foo != &bar)
        {
          abort();
        }*/
        if ( &foo != &bar)
           abort();
        return 0;
}
when compilating weaK_0.c with fllowing cmmand :
i586-target-linux-gnu-gcc weak_0.c -flto -o weak

run week

expected result: return 0;
actual   result: abort();



More information about the Gcc-bugs mailing list