Bug 49899 - ICE when redeclaring a static function as weak
Summary: ICE when redeclaring a static function as weak
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-29 10:34 UTC by Nick Clifton
Modified: 2011-07-29 10:34 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Proposed patch and new testcase (503 bytes, application/octet-stream)
2011-07-29 10:34 UTC, Nick Clifton
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Clifton 2011-07-29 10:34:47 UTC
Created attachment 24862 [details]
Proposed patch and new testcase

If an already defined static function is redefined as being both public and weak, the compiler generates an ICE:

    % cat test.c
    static long foo (void) { return 0; }
    long foo (void)  __attribute__((weak));

    % gcc test.c
    test.c:1:12: internal compiler error: in function_and_variable_visibility, at ipa.c:408

The uploaded patch is an attempt to fix this by adding a check into varasm.c:merge_weak().  I was not sure however whether the redeclaration is an error, or if it should be honoured and the function made non-static.