The testcase below causes multiple definitions if current_namespace with compiling with -O on ppc and ppc64:
.LFE2: .size _Z24add_defined_foreign_typev,.-_Z24add_defined_foreign_typev .section ".bss" .align 2 .set .LANCHOR0,. + 0 .type current_namespace, @object .size current_namespace, 4 current_namespace: .zero 4 .type current_namespace, @object .size current_namespace, 4 current_namespace: .zero 4 .section .eh_frame,"a",@progbits -fno-section-anchors fixes it. void *f1(); void f2(void *); static void *current_namespace = f1(); void *namespaced_name(void *ns = current_namespace); void add_defined_foreign_type() { void *k; k = namespaced_name(); f2(k); // make sure k isn't optimized out } -- Summary: [4.2 Regression] -fsection-anchors causes multiple definitions Product: gcc Version: 4.2.0 Status: UNCONFIRMED Keywords: wrong-code Severity: blocker Priority: P3 Component: rtl-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: rguenth at gcc dot gnu dot org GCC target triplet: powerpc*-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31373