https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79582
Bug ID: 79582 Summary: Wrong mangled name for stdcall functions with templated arguments when referenced directly from vtbl. Product: gcc Version: 6.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: jacek at codeweavers dot com Target Milestone: --- Created attachment 40764 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=40764&action=edit test case It was originally reported in mingw-w64 build of Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=1336527 The attached test case shows the problem: $ i686-w64-mingw32-g++ -c test.i -o test.o $ i686-w64-mingw32-nm child.o |grep test_virtual U __ZN6Parent12test_virtualE16templated_structIiE@4 Note that stdcall suffix should be @8: the function has both implicit this pointer and templated struct of pointer size. I experimented with this a bit and it seems to be caused by a combination of stdcall and templated argument. The suffix is always @4 even if I add more simple arguments. The bug happens only if such function is needed by the vtbl itself. Other references to the function work as expected. I will also attach a test that shows the bug by failing to link: $ i686-w64-mingw32-g++ -c parent.cpp -o parent.o && i686-w64-mingw32-g++ -c child.cpp -o child.o && i686-w64-mingw32-g++ parent.o child.o -o test.exe child.o:child.cpp:(.rdata$_ZTV5Child[__ZTV5Child]+0xc): undefined reference to `Parent::test_virtual(templated_struct<int>)@4' collect2: error: ld returned 1 exit status