gcc-2.95 bug: stdcall rubs off on templates

Mumit Khan khan@xraylith.wisc.EDU
Thu Sep 30 19:57:00 GMT 1999


kalle@algorithmica.se (Karl-Johan Johnsson) writes:
> The problem appears with the following versions of GCC:
> 
> gcc-2.95 linux -> i586-mingw32 cross compiler
> gcc-2.95.1 linux -> i586-mingw32 cross compiler
> gcc-2.95 i386-mingw32 native (Mumit Khan's binary distribution)
> 
> but not with the version of gcc included in cygwin-b20 (egcs-1.1).
> 
> When compiling the following program, the implicit instantiation
> of A<0>::f() is decorated with a trailing '@4' (as if it had
> been declared __stdcall), leading to an undefined reference:
> 
> bug.cpp:
> ----8<--[snip]-------
> template <int> class A
> {
> public:
>     static void* f(int);
> };
> 
> template <int i> void* A<i>::f(int)
> {
>     return 0;
> }
> 
> int main()
> {
>     return !A<0>::f(0);
> }
> 
> void* __attribute__((__stdcall__)) foo(int);


Thanks for the bug report. This is an unfortunate bug in the C++ parser,
and I haven't had much time to look at it yet.

For a simplified testcase, see:

   Linkname: (C++) parser bug in handling fn attributes
   URL: http://egcs.cygnus.com/ml/gcc-bugs/1999-07/msg00835.html
   
Regards,
Mumit



More information about the Gcc-bugs mailing list