[Bug c/17555] New: function visibility attribute in definition misinterpreted
drepper at redhat dot com
gcc-bugzilla@gcc.gnu.org
Sat Sep 18 21:16:00 GMT 2004
When a function visibility attribute is used in the definition of a function and
the return value type of the function is a pointer, the attribute is
misinterpreted as belonging to the type. Example:
#if PTR
struct foo
{
int a;
};
#define rval (void *) 0
struct foo *
#else
#define rval 0
int
#endif
__attribute((visibility("hidden")))
bar (void)
{
return rval;
}
Compiling with
gcc4 -c -O -Wall y.c
leads to no warning and the symbol 'bar' is defined as a hidden symbol:
$ readelf -s y.o|grep bar
7: 00000000 10 FUNC GLOBAL HIDDEN 1 bar
Compiling with
gcc4 -c -O -Wall y.c _DPTR
leads to a warning
y.c:14: warning: 'visibility' attribute ignored on non-class types
and bar is not defined hidden:
$ readelf -s y.o|grep bar
7: 00000000 10 FUNC GLOBAL DEFAULT 1 bar
I suspect this affects all ELF targets.
--
Summary: function visibility attribute in definition
misinterpreted
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: drepper at redhat dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC host triplet: i386-redhat-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17555
More information about the Gcc-bugs
mailing list