different visibility warnings for std::out_of_range destructor

Manfred Schwind lists@mani.de
Sun Apr 25 10:37:00 GMT 2010


working on Mac OS X 10.6 with gcc 4.2 and llvmgcc 4.2. Using boost 1.42.0.
I try to make my project free of "different visibility" warnings. I am using e.g. boost and other stuff, and I compiled everything I use with -fvisibility=hidden.
This worked great so far - all "different visibility" warnings are gone (before, I had hundreds of them).

... until now:

In a source file I used boost::current_exception() for the first time. Now for this source file I get this linker warning:

ld: warning: std::out_of_range::~out_of_range()has different visibility (default) in [...]/libboost_thread-xgcc40-mt-1_42.a(thread.o) and (hidden) in [...]/MySource.o

I know that visibility is important for exceptions, and I saw that e.g. in the stdexcept header there is the following pragma at the beginning:
#pragma GCC visibility push(default)

So the exceptions should have the correct (default) visibility. In the compiled boost library this is correct. But why is it not correct in the object file of my source? There are several other exceptions defined in "stdexcept" - what's so special about out_of_range?
When I comment out the line containing the boost::current_exception() call, the linker warning is gone.

I looked at the preprocessed file, but I can't see anything special. I see the stdexcept header included, correct with the above #pragma etc. I've no idea why the out_of_range destructor has "hidden" visibility in the object file of my source.

Any ideas?

The only difference is that boost was compiled with gcc 4.0. But even if I use gcc 4.0 for all my sources, I get the same linker warning. Same for llvmgcc 4.2.

http://mani.de - friendly software
iVolume - listen to music hands-free
LittleSecrets - the encrypted notepad
Sahara - sand in your pocket
Watchdog - baffle the curious

More information about the Gcc-help mailing list