[Bug c++/43376] template member function instantiations are not hidden if the class has default visibility and -fvisibility-ms-compat is used

fjoe at samodelkin dot net gcc-bugzilla@gcc.gnu.org
Wed Mar 17 07:10:00 GMT 2010



------- Comment #3 from fjoe at samodelkin dot net  2010-03-17 07:09 -------
The source of library "bar" is:

--- cut here ---
#include "foo.h"

#ifdef _MSC_VER
#define BAR_API __declspec(dllexport)
#else
#define BAR_API __attribute__((visibility("default")))
#endif

void BAR_API
bar()
{
        Foo foo;
        foo.foo(5);
}
--- cut here ---

And Foo::foo is visible in "bar":

[Wed Mar 17 12:27:12] kenny:~/work/export$g++44 -c -fvisibility-ms-compat
bar.cc
[Wed Mar 17 12:27:20] kenny:~/work/export$readelf -sW bar.o | grep foo
    15: 00000000    45 FUNC    WEAK   DEFAULT    6 _ZN3Foo3fooIiEEvRKT_


When I compile the same using Visual Studio (.DLL configuration) I get the
following output from objdump (cygwin objdump):

mkhon@pond /cygdrive/c/Users/mkhon/export$ objdump -x bar.dll
[...]
The Export Tables (interpreted .rdata section contents)

Export Flags                    0
Time/Date stamp                 4ba07f9e
Major/Minor                     0/0
Name                            000c7302 bar.dll
Ordinal Base                    1
Number in:
        Export Address Table            00000001
        [Name Pointer/Ordinal] Table    00000001
Table Addresses
        Export Address Table            000c72f8
        Name Pointer Table              000c72fc
        Ordinal Table                   000c7300

Export Address Table -- Ordinal Base 1
        [   0] +base[   1] 3ab7c Export RVA

[Ordinal/Name Pointer] Table
        [   0] ?bar@@YAXXZ
[...]

As you can see there are no Foo::foo symbols exported.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43376



More information about the Gcc-bugs mailing list