Bug 198967

Summary: new C++ visibility doesn't work as expected
Product: [Fedora] Fedora Reporter: Bill Nottingham <notting>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED WONTFIX QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: rawhideCC: bkoz, caolanm, jason, rvokal
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2007-09-22 16:49:16 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Bill Nottingham 2006-07-15 03:35:08 UTC
Version-Release number of selected component (if applicable):

4.1.1-7

WARNING: C++ doofus here.

Consider the following foo.cpp:

#include <list>

class __attribute__((visibility("default"))) Foo {
public:
        Foo();
        ~Foo();
        std::list<std::string> Bar();

};

$ g++ -Wall -c -o foo.o foo.cpp -fvisibility=hidden
foo.cpp:8: warning: âstd::list<std::basic_string<char, std::char_traits<char>,
std::allocator<char> >, std::allocator<std::basic_string<char,
std::char_traits<char>, std::allocator<char> > > > Foo::Bar()â declared with
greater visibility than its type

Shouldn't the standard libstdc++ template types (std::list, etc) be visible?

Adding #pragma GCC visiblity push & pop around the "#include <list>" fixes it,
but that seems wrong.

Comment 1 Bill Nottingham 2006-07-15 03:37:18 UTC
Erm, assume there's a #include <string> in there. :)  It still errors...



Comment 2 Jakub Jelinek 2006-07-15 07:44:35 UTC
I thought libstdc++ (particularly bits/c++config) already uses
__attribute__((visibility ("default"))) on the std namespace (and similar
namespaces), but apparently it doesn't.

Comment 3 Jakub Jelinek 2006-07-15 11:09:12 UTC
This isn't anything new BTW, it has never been there so far and thus code
without default visibility around the standard headers has always been broken.

Comment 4 Bill Nottingham 2006-07-17 13:31:49 UTC
Ok, then rather than munge all the #include statements in the package, I can
turn off the visibility flag for the build for now. Any chance that at least
libstdc++ could be fixed to have proper visiblity in the headers?

Comment 5 Jakub Jelinek 2007-09-22 16:49:16 UTC
GCC 4.3 will have that, but for 4.1 such changes are IMHO way too invasive.