Bug 54666

Summary: when do lto opitimizing with attribute (weak,alias), it will produce wrong code
Product: gcc Reporter: huangcunjian <hcj20080469>
Component: middle-endAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: normal CC: hubicka
Priority: P3 Keywords: lto, wrong-code
Version: 4.7.2   
Target Milestone: ---   
See Also: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=32219
Host: Target:
Build: Known to work: 5.1.0
Known to fail: 4.7.2, 4.8.0, 4.9.3 Last reconfirmed: 2012-09-24 00:00:00
Bug Depends on:    
Bug Blocks: 92932    

Description huangcunjian 2012-09-22 02:05:40 UTC
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();
Comment 1 Richard Biener 2012-09-24 09:33:02 UTC
Confirmed.  4.6.x segfaults for me.
Comment 2 Andrew Pinski 2021-09-22 07:01:54 UTC
This was fixed for GCC 5.1.0.  The problem is the same as PR 32219 really.
Comment 3 Andrew Pinski 2021-09-22 07:02:48 UTC
(In reply to Andrew Pinski from comment #2)
> This was fixed for GCC 5.1.0.  The problem is the same as PR 32219 really.

That is the patch which fixes PR 32219 fixed this one.