Bug 28449 - failed to build DSO with STL and hidden visibility enabled
Summary: failed to build DSO with STL and hidden visibility enabled
Status: RESOLVED DUPLICATE of bug 19664
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2006-07-20 20:13 UTC by Maks Polunin
Modified: 2006-07-20 22:01 UTC (History)
28 users (show)

See Also:
Known to work:
Known to fail:
Last reconfirmed:


Note You need to log in before you can comment on or make changes to this bug.
Description Maks Polunin 2006-07-20 20:13:54 UTC
simplified test-case:
#include <set>

class __attribute__ ((visibility("default"))) foo {
    typedef std::set<int> int_set;
    int_set::const_iterator begin() const;

    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)
Comment 1 Andrew Pinski 2006-07-20 22:01:49 UTC

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