This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/67040] New: gcc-5.2 fails with flat namespaces on the mac os


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]