[Bug c++/17542] New: Visibility attribute ignored when it precedes class head
austern at apple dot com
gcc-bugzilla@gcc.gnu.org
Fri Sep 17 23:14:00 GMT 2004
Consider the following file:
__attribute__((visibility("default"))) struct foo { virtual ~foo(); };
struct bar { virtual ~bar(); } __attribute__((visibility("default")));
foo::~foo() { }
bar::~bar() { }
My expectation would be that classes foo and bar would both get default visibility. That's not what
happens:
[isolde:tmp]$ /work/root/bin/g++ -fvisibility=hidden -c v5.cc
[isolde:tmp]$ nm -m v5.o
00000208 (__TEXT,__text) external __ZN3barD0Ev
00000000 (absolute) external __ZN3barD0Ev.eh
000001a0 (__TEXT,__text) external __ZN3barD1Ev
00000000 (absolute) external __ZN3barD1Ev.eh
00000138 (__TEXT,__text) external __ZN3barD2Ev
00000000 (absolute) external __ZN3barD2Ev.eh
000000d0 (__TEXT,__text) private external __ZN3fooD0Ev
00000000 (absolute) private external __ZN3fooD0Ev.eh
00000068 (__TEXT,__text) private external __ZN3fooD1Ev
00000000 (absolute) private external __ZN3fooD1Ev.eh
00000000 (__TEXT,__text) private external __ZN3fooD2Ev
00000000 (absolute) private external __ZN3fooD2Ev.eh
00000270 (__DATA,__datacoal_nt) weak external __ZTI3bar
00000280 (__DATA,__datacoal_nt) weak private external __ZTI3foo
00000278 (__DATA,__datacoal_nt) weak external __ZTS3bar
00000288 (__DATA,__datacoal_nt) weak private external __ZTS3foo
000002a0 (__DATA,__const) external __ZTV3bar
00000290 (__DATA,__const) private external __ZTV3foo
(undefined) external __ZTVN10__cxxabiv117__class_type_infoE
(undefined [lazy bound]) external __ZdlPv
(undefined) external dyld_stub_binding_helper
[isolde:tmp]$
This is certainly wrong. If putting the visibility attribute at the beginning of the class definition is
syntactly valid, then that visibility should be respected. If this is a syntax error then it should be
diagnosed as such. Silently ignoring the attribute is wrong.
--
Summary: Visibility attribute ignored when it precedes class head
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: austern at apple dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: powerpc-apple-darwin7.5.0
GCC host triplet: powerpc-apple-darwin7.5.0
GCC target triplet: powerpc-apple-darwin7.5.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17542
More information about the Gcc-bugs
mailing list