User account creation filtered due to spam.

Bug 49899 - ICE when redeclaring a static function as weak
Summary: ICE when redeclaring a static function as weak
Status: NEW
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
Keywords: ice-on-invalid-code
Depends on:
Reported: 2011-07-29 10:34 UTC by Nick Clifton
Modified: 2016-02-17 14:26 UTC (History)
1 user (show)

See Also:
Known to work:
Known to fail: 6.0
Last reconfirmed: 2016-02-13 00:00:00

Proposed patch and new testcase (503 bytes, patch)
2011-07-29 10:34 UTC, Nick Clifton
Details | Diff

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.
Comment 1 Andrew Pinski 2016-02-13 08:16:27 UTC
Confirmed, I had this bug reported to me too.  Still fails on the trunk.
Comment 2 Nick Clifton 2016-02-17 14:26:01 UTC
I have proposed the patch on the gcc-patches list: