http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49899
Summary: ICE when redeclaring a static function as weak Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end AssignedTo: unassig...@gcc.gnu.org ReportedBy: ni...@redhat.com Created attachment 24862 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24862 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.