[LLVMbugs] [Bug 23034] New: GCC ABI incompatibility visible in forward_as_tuple
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Thu Mar 26 09:42:36 PDT 2015
https://llvm.org/bugs/show_bug.cgi?id=23034
Bug ID: 23034
Summary: GCC ABI incompatibility visible in forward_as_tuple
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: Axel.Naumann at cern.ch
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
Classification: Unclassified
Created attachment 14103
--> https://llvm.org/bugs/attachment.cgi?id=14103&action=edit
Reproducer. Apologies for its preprocessed size :-(
With $ gcc --version
gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2
(and other 4.8.1 from RedHat)
and $ clang --version
clang version 3.7.0 (trunk 233280)
I get
clang++ -std=c++11 -c clanggcc.cxx -o clang.o
g++ -std=c++11 clanggcc.cxx clang.o -o a.out
./a.out
gcc: &rval=0x7fff3c1b2700
gcc: &c_str()=0xcec028
tpl: &c_str()=0xcec028
tpl: c_str()=a
clang: &rval=0x7fff3c1b2718
clang: &c_str()=0xcec028
make: *** [test] Segmentation fault
with attached code.
The linker uses GCC's version of forward_as_tuple. GCC sets %rsi and %rdi to
call it; clang only sets %rdi. The implementation of forward_as_tuple compiled
by GCC needs both %rsi and %rdi.
And yes - not part of this test but clang's implementation of forward_as_tuple
only needs %rdi - so clang is consistent but incompatible with GCC.
Assembly of the relevant part of the GCC call:
0x00000000004009e6 <+86>: callq 0x400ab1
<std::move<std::string&>(std::string&)>
0x00000000004009eb <+91>: mov %rax,%rdx
0x00000000004009ee <+94>: lea -0x10(%rbp),%rax
0x00000000004009f2 <+98>: mov %rdx,%rsi
0x00000000004009f5 <+101>: mov %rax,%rdi
0x00000000004009f8 <+104>: callq 0x400b94
<std::forward_as_tuple<std::string>(std::string&&)>
...and for clang:
0x0000000000400d4f <+95>: callq 0x400ab1
<std::move<std::string&>(std::string&)>
0x0000000000400d54 <+100>: mov %rax,%rdi
0x0000000000400d57 <+103>: callq 0x400b94
<std::forward_as_tuple<std::string>(std::string&&)>
with GCC's forward_as_tuple being:
=> 0x0000000000400b94 <+0>: push %rbp
0x0000000000400b95 <+1>: mov %rsp,%rbp
0x0000000000400b98 <+4>: sub $0x10,%rsp
0x0000000000400b9c <+8>: mov %rdi,-0x8(%rbp)
0x0000000000400ba0 <+12>: mov %rsi,-0x10(%rbp)
0x0000000000400ba4 <+16>: mov -0x10(%rbp),%rax
0x0000000000400ba8 <+20>: mov %rax,%rdi
0x0000000000400bab <+23>: callq 0x400aea
<std::forward<std::string>(std::remove_reference<std::string>::type&)>
0x0000000000400bb0 <+28>: mov %rax,%rdx
0x0000000000400bb3 <+31>: mov -0x8(%rbp),%rax
0x0000000000400bb7 <+35>: mov %rdx,%rsi
0x0000000000400bba <+38>: mov %rax,%rdi
0x0000000000400bbd <+41>: callq 0x400b64
<std::tuple<std::string&&>::tuple<std::string, void>(std::string&&)>
0x0000000000400bc2 <+46>: mov -0x8(%rbp),%rax
0x0000000000400bc6 <+50>: leaveq
0x0000000000400bc7 <+51>: retq
Help!
Cheers, Axel.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150326/0d2133c8/attachment.html>
More information about the llvm-bugs
mailing list