<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - clang generate incompatible code for std::tie"
href="https://bugs.llvm.org/show_bug.cgi?id=34427">34427</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>clang generate incompatible code for std::tie
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>4.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>LLVM Codegen
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>wengxt@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>For example:
#include <tuple>
int main() {
int a = 1, b = 2;
auto t = std::tie(a, b);
return 0;
}
Compile with -std=c++14 -O0 for both clang++ and g++.
Problem is for clang++ and g++ it generate code that return value in different
style, which would cause crash when a clang++ compiled lib and g++ compiled lib
linked together because std symbol is always visible for libstdcxx.
g++ produces:
0000000000400768 <_ZSt3tieIJiiEESt5tupleIJDpRT_EES3_>:
400768: 55 push %rbp
400769: 48 89 e5 mov %rsp,%rbp
40076c: 48 83 ec 20 sub $0x20,%rsp
400770: 48 89 7d f8 mov %rdi,-0x8(%rbp)
400774: 48 89 75 f0 mov %rsi,-0x10(%rbp)
400778: 48 89 55 e8 mov %rdx,-0x18(%rbp)
40077c: 48 8b 55 e8 mov -0x18(%rbp),%rdx
400780: 48 8b 4d f0 mov -0x10(%rbp),%rcx
400784: 48 8b 45 f8 mov -0x8(%rbp),%rax
400788: 48 89 ce mov %rcx,%rsi
40078b: 48 89 c7 mov %rax,%rdi
40078e: e8 a7 ff ff ff callq 40073a
<_ZNSt5tupleIJRiS0_EEC1IvLb1EEES0_S0_>
400793: 48 8b 45 f8 mov -0x8(%rbp),%rax
400797: c9 leaveq
400798: c3 retq
400799: 0f 1f 80 00 00 00 00 nopl 0x0(%rax)
while clang++ produces:
0000000000000850 <_ZSt3tieIJiiEESt5tupleIJDpRT_EES3_>:
850: 55 push %rbp
851: 48 89 e5 mov %rsp,%rbp
854: 48 83 ec 20 sub $0x20,%rsp
858: 48 89 7d e8 mov %rdi,-0x18(%rbp)
85c: 48 89 75 e0 mov %rsi,-0x20(%rbp)
860: 48 8b 75 e8 mov -0x18(%rbp),%rsi
864: 48 8b 55 e0 mov -0x20(%rbp),%rdx
868: 48 8d 7d f0 lea -0x10(%rbp),%rdi
86c: e8 0f 00 00 00 callq 880
<_ZNSt5tupleIJRiS0_EEC2IvLb1EEES0_S0_>
871: 48 8b 45 f0 mov -0x10(%rbp),%rax
875: 48 8b 55 f8 mov -0x8(%rbp),%rdx
879: 48 83 c4 20 add $0x20,%rsp
87d: 5d pop %rbp
87e: c3 retq
87f: 90 nop
$ clang -v
clang version 4.0.1 (tags/RELEASE_401/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-pc-linux-gnu/6.3.1
Found candidate GCC installation:
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.3.1
Found candidate GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1
Found candidate GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/6.3.1
Selected GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.3.1
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /chakra/core/gcc/src/gcc/configure --prefix=/usr
--libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=<a href="https://chakraos.org/bugtracker">https://chakraos.org/bugtracker</a>
--enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared
--enable-threads=posix --enable-libmpx --with-system-zlib --with-isl
--enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu
--disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object
--enable-linker-build-id --enable-lto --enable-plugin
--enable-install-libiberty --with-linker-hash-style=gnu
--enable-gnu-indirect-function --enable-multilib --disable-werror
--enable-checking=release --with-default-libstdcxx-abi=gcc4-compatible
Thread model: posix
gcc version 6.3.1 20170306 (GCC)</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>