Bug 833440

Summary: gcc 4.7/4.8 Regression: visibility attribute for class is not passed to its members
Product: Red Hat Developer Toolset Reporter: Frank Danapfel <fdanapfe>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED ERRATA QA Contact: qe-baseos-tools-bugs
Severity: high Docs Contact:
Priority: high    
Version: unspecifiedCC: law, linux, mnewsome, mpolacek, pkovar
Target Milestone: alpha   
Target Release: 1.1   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: devtoolset-1.1-gcc-4.7.1-7.el6 Doc Type: Release Note
Doc Text:
The GCC compiler now properly passes the visibility attribute from a class to its members.
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-01-22 14:35:38 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Frank Danapfel 2012-06-19 13:16:11 UTC
This was already reported upstream by SAP in GCC Bugzilla – Bug 52973:

"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."

According to the upstream bugzilla, this is fixed in gcc 4.7.1. It would be useful for SAP if the fix could also be integrated in the gcc shipped with the Developer Toolset.

Comment 5 Matt Newsome 2012-08-14 12:09:33 UTC
Jakub indicated fixed in devtoolset-1.1-gcc-4.7.1-7.el6 so attaching to erratum RHEA-2012:13624-01

Comment 9 errata-xmlrpc 2013-01-22 14:35:38 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHEA-2013-0177.html