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: [email protected]
        ReportedBy: [email protected]
                CC: [email protected], [email protected]
    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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to