http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52973
Bug #: 52973 Summary: visibility attribute for class is not passed to its members Classification: Unclassified Product: gcc Version: 4.7.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: regression AssignedTo: unassig...@gcc.gnu.org ReportedBy: holger.h...@sap.com In following code, gcc-4.7 does not accept the visibility attribute defined in the class declaration: template <class T> class __attribute__((visibility("default"))) a { public: /* A */ static int c; }; class __attribute__((visibility("default"))) b : a <b> {}; template<> /* B */ int a<b>::c = 0; With g++-4.7, a<b>::c is hidden, with g++-4.6 (and before) it is not. $ g++-4.7 -fvisibility=hidden -c def.cpp && objdump -Ct def.o | grep "a<b>" 0000000000000000 g O .bss 0000000000000004 .hidden a<b>::c $ g++-4.6 -fvisibility=hidden -c def.cpp && objdump -Ct def.o | grep "a<b>" 0000000000000000 g O .bss 0000000000000004 a<b>::c Setting the default visibility at /* A */ or /* B */ works with g++-4.7, but I think that it still should work also with the code above.