simplified test-case: #include <set> class __attribute__ ((visibility("default"))) foo { public: typedef std::set<int> int_set; int_set::const_iterator begin() const;
private: int_set m_set; }; foo::int_set::const_iterator foo::begin() const { return m_set.begin(); } compile it: $ g++-4.2.0-alpha20060715 -fPIC -shared -Wall -fvisibility=hidden test.cc -o test.so test.cc:6: warning: âstd::_Rb_tree_const_iterator<int> foo::begin() constâ declared with greater visibility than its type test.cc:3: warning: âfooâ declared with greater visibility than the type of its field âfoo::m_setâ foo::begin()/m_set are not exported it can be repaired by adding typedef for const_iterator and placing it and typedef for set outside of class or wrapping include #pragma GCC visibility push(default) #include <set> #pragma GCC visibility pop at this case if client of DSO also includes <set> before including my header - he will get the same warning as above, but code seems to be working. so, question is - shouldn't push/pop visibility placed in stl headers? there were no such problem w/ gcc-4.2.0_alpha20060603 $ g++-4.2.0-alpha20060715 -v Using built-in specs. Target: i686-pc-linux-gnu Configured with: /var/tmp/portage/gcc-4.2.0_alpha20060715/work/gcc-4.2-20060715/configure --prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/4.2.0-alpha20060715 --includedir=/usr/lib/gcc/i686-pc-linux-gnu/4.2.0-alpha20060715/include --datadir=/usr/share/gcc-data/i686-pc-linux-gnu/4.2.0-alpha20060715 --mandir=/usr/share/gcc-data/i686-pc-linux-gnu/4.2.0-alpha20060715/man --infodir=/usr/share/gcc-data/i686-pc-linux-gnu/4.2.0-alpha20060715/info --with-gxx-include-dir=/usr/lib/gcc/i686-pc-linux-gnu/4.2.0-alpha20060715/include/g++-v4 --host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --disable-altivec --enable-nls --without-included-gettext --with-system-zlib --disable-checking --disable-werror --disable-libunwind-exceptions --disable-multilib --disable-libmudflap --disable-libssp --disable-libgcj --enable-languages=c,c++ --enable-shared --enable-threads=posix --enable-bootstrap --enable-__cxa_atexit --enable-clocale=gnu Thread model: posix gcc version 4.2.0-alpha20060715 (experimental) (Gentoo 4.2.0_alpha20060715) -- Summary: failed to build DSO with STL and hidden visibility enabled Product: gcc Version: 4.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: ph0enix at ngs dot ru http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28449