Bug 33399 - [4.2 regression] -fvisibility=hidden not working after including STL headers
Summary: [4.2 regression] -fvisibility=hidden not working after including STL headers
Status: RESOLVED DUPLICATE of bug 32470
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.2.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-09-11 20:37 UTC by Dirk Mueller
Modified: 2007-09-11 22:39 UTC (History)
5 users (show)

See Also:
Host: i686-suse-linux
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dirk Mueller 2007-09-11 20:37:06 UTC
Hi, 

g++ 4.2.1 doesn't seem to apply hidden visibility to classes after including e.g. <ostream>. 

the following testcase was reduced: 

=== Cut ===
namespace std  __attribute__ ((__visibility__ ("default")))
{
  template < typename A > class C;
  template < typename A > int foo (C < A > *);

  template < typename A > class C
  {
  public:
    friend int foo<>(C <A > *);
  };
  extern template class C < char >;
}

struct TestClass
{
  void hidden();
};
void TestClass::hidden() {}
=== cut ===
g++ -O1 -fvisibility=hidden -fvisibility-inlines-hidden -fPIC testcase.cc -c -o nostl.o
g++ -shared -o libnostl.so nostl.o
nm -CD libnostl.so | grep TestClass 

gives

0000048c T TestClass::hidden()


the symbol is properly hidden if I put the namespace std into default visibility or otherwise try to reduce the code further.
Comment 1 Gerhard Dirschl 2007-09-11 21:38:49 UTC
This seems to be a duplicate of
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32470
I made a patch proposal there.
Comment 2 Dirk Mueller 2007-09-11 22:39:13 UTC

*** This bug has been marked as a duplicate of 32470 ***