This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
(C++) parser bug in handling fn attributes
- To: gcc-bugs at gcc dot gnu dot org
- Subject: (C++) parser bug in handling fn attributes
- From: Mumit Khan <khan at xraylith dot wisc dot EDU>
- Date: Mon, 26 Jul 1999 20:44:16 -0500
The following code shows a bug in the C++ parser when dealing with
function attributes. The C parser does the right thing. I'm using
__stdcall__ on x86/win32 since it's easy to see. On Linux, the same
problem occurs, but more silently due to non-decoration of stdcall
functions.
extern void *foo (int);
extern void * __attribute__((__stdcall__)) bar (int);
extern void *foo (int);
int main ()
{
foo (0);
}
Now see the symbols below, especially the line marked WRONG, which it is.
$ i586-cygwin32-gcc -c c++-attrib-fn-bug.cc
$ i586-cygwin32-nm c++-attrib-fn-bug.o
00000000 b .bss
00000000 d .data
00000000 t .text
00000000 t ___gnu_compiled_cplusplus
U ___main
U _foo__Fi@4 <<<<< WRONG, should be _foo__Fi.
00000000 T _main
00000000 t gcc2_compiled.
If I change the prototype of bar() to not match the prototype of foo(),
the problem goes away[1]; if I change the position of the attribute to
come *before* the return type, the problem goes away[2].
[1] This is OK.
extern void *foo (int);
extern void * __attribute__((__stdcall__)) bar (char);
extern void *foo (int);
[2] And so is this.
extern void *foo (int);
extern __attribute__((__stdcall__)) void *bar (char);
extern void *foo (int);
This exists in both release and mainline, and causing let's just say
interesting link time errors.
Regards,
Mumit