[LLVMbugs] [Bug 12684] New: Calling convention with MinGW32 4.7.x issue
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Fri Apr 27 08:16:32 PDT 2012
http://llvm.org/bugs/show_bug.cgi?id=12684
Bug #: 12684
Summary: Calling convention with MinGW32 4.7.x issue
Product: clang
Version: trunk
Platform: PC
OS/Version: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: C++
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: japplegame at gmail.com
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
Classification: Unclassified
I tried to compile very simple "Hello World" application by clang (trunk built
with mingw-w64 4.7.0). Everything is ok, but running exe causes SIGSEGV.
After comparsion asm generated by clang++ and "native" mingw g++, I found
clang++ uses different calling convention for class method calls. This is
leading to incompatibility between clang++ and libstdc++ from mingw.
GCC 4.7.x (Windows x86 targets) uses __thiscall for class methods (see
http://gcc.gnu.org/gcc-4.7/changes.html), but clang++ uses __cdecl.
//test.cpp
#include <iostream>
using namespace std;
int main()
{
cout << "Hello world!" << endl;
return 0;
}
>clang++ -v
clang version 3.2 (trunk 155632)
Target: i686-pc-mingw32
Thread model: posix
>clang++ -S -o test-clang.asm test.cpp
>g++ -S -o test-gcc.asm test.cpp
Compare operator<<(endl) part of generated asm:
GCC:
movl $__ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_, (%esp)
movl %eax, %ecx
call __ZNSolsEPFRSoS_E
Clang:
leal __ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_, %ecx
movl %eax, (%esp)
movl %ecx, 4(%esp)
calll __ZNSolsEPFRSoS_E
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list