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.
This seems to be a duplicate of http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32470 I made a patch proposal there.
*** This bug has been marked as a duplicate of 32470 ***