Bug#536570: gcc-4.3: Redeclaration with different visibility isn't spotted when using -fvisibility=hidden
Package: gcc-4.3
Version: 4.3.3-13
Severity: normal
When using -fvisibility=hidden to define the global visibility to hidden,
declaring a function with the global visibility, then redeclaring it
with visibility default results in the symbol being exported.
$ cat > test.c <<EOF
extern int foo();
__attribute__((visibility("default"))) int foo() {
return 42;
}
EOF
$ gcc -fvisibility=hidden -o test.o -c test.c
$ objdump -x test.o | grep foo
0000000000000000 g F .text 000000000000000b foo
When using #pragma GCC visibility push(hidden) to define the global
visibility to hidden, declaring a function with the global visibilty,
then redeclaring it with visibility default results in a warning about
this redeclaration, and the symbol being hidden.
$ cat > test.c <<EOF
#pragma GCC visibility push(hidden)
extern int foo();
__attribute__((visibility("default"))) int foo() {
return 42;
}
$ gcc -o test.o -c test.c
test.c:5: warning: redeclaration of ‘foo’ with different visibility (old visibility preserved)
test.c:3: warning: previous declaration of ‘foo’ was here
$ objdump -x test.o | grep foo
0000000000000000 g F .text 000000000000000b .hidden foo
I think the latter is better, and the inconsistency is harmful.
Mike
-- System Information:
Debian Release: squeeze/sid
APT prefers unstable
APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.30-1-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
Versions of packages gcc-4.3 depends on:
ii binutils 2.19.51.20090704-1 The GNU assembler, linker and bina
ii cpp-4.3 4.3.3-13 The GNU C preprocessor
ii gcc-4.3-base 4.3.3-13 The GNU Compiler Collection (base
ii libc6 2.9-13 GNU C Library: Shared libraries
ii libgcc1 1:4.4.0-7 GCC support library
Versions of packages gcc-4.3 recommends:
ii libc6-dev 2.9-13 GNU C Library: Development Librari
Versions of packages gcc-4.3 suggests:
pn gcc-4.3-doc <none> (no description available)
pn gcc-4.3-locales <none> (no description available)
pn gcc-4.3-multilib <none> (no description available)
pn libgcc1-dbg <none> (no description available)
pn libgomp1-dbg <none> (no description available)
pn libmudflap0-4.3-dev <none> (no description available)
pn libmudflap0-dbg <none> (no description available)
-- no debconf information
Reply to: