This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the EGCS project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

(C++) parser bug in handling fn attributes


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]