https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67040
Bug ID: 67040 Summary: gcc-5.2 fails with flat namespaces on the mac os Product: gcc Version: 5.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: balaji at anl dot gov Target Milestone: --- gcc-5.2 causes bad library builds on the mac os, when built with flat namespaces, and with no optimizations. The following simple program reproduces the problem: {{{ % cat foo.c #include <stdio.h> void bar(void) { } void foo(void *s) { bar(); } }}} {{{ % cat test.c #include <stdio.h> void foo(void *s); int main() { foo(NULL); return 0; } }}} {{{ % gcc -dynamiclib foo.c -o libfoo.dylib -Wl,-flat_namespace % gcc -L. test.c -lfoo % ./a.out Segmentation fault: 11 }}} Either removing the `-Wl,-flat_namespace` option or adding some level of optimization, such as `-O2` to the library build fixes this issue.