<html>
<head>
<base href="http://llvm.org/bugs/" />
</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 --- - Error compiling std::pair constructor with gcc >= 4.7"
href="http://llvm.org/bugs/show_bug.cgi?id=22771">22771</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Error compiling std::pair constructor with gcc >= 4.7
</td>
</tr>
<tr>
<th>Product</th>
<td>libc++
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>All Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>dimitry@andric.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu, mclow.lists@gmail.com
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>One of the FreeBSD developers attempted to build the -CURRENT source tree
(which includes a relatively new snapshot of libc++) using gcc 4.9.1, and
encountered an error about std::make_pair during compilation of clang's
lib/AST/DeclBase.cpp [1]:
In file included from
/usr/src/lib/clang/libclangast/../../../contrib/llvm/include/llvm/Support/type_traits.h:17:0,
from
/usr/src/lib/clang/libclangast/../../../contrib/llvm/include/llvm/Support/Casting.h:19,
from
/usr/src/lib/clang/libclangast/../../../contrib/llvm/tools/clang/include/clang/Basic/LLVM.h:22,
from
/usr/src/lib/clang/libclangast/../../../contrib/llvm/tools/clang/include/clang/AST/AttrIterator.h:17,
from
/usr/src/lib/clang/libclangast/../../../contrib/llvm/tools/clang/include/clang/AST/DeclBase.h:17,
from
/usr/src/lib/clang/libclangast/../../../contrib/llvm/tools/clang/lib/AST/DeclBase.cpp:14:
/usr/obj/usr/src/tmp/usr/include/c++/v1/type_traits: In instantiation of
'struct std::__1::__is_convertible<const clang::StoredDeclsList&,
clang::StoredDeclsList, 0u, 0u>':
/usr/obj/usr/src/tmp/usr/include/c++/v1/type_traits:943:62: required from
'struct std::__1::is_convertible<const clang::StoredDeclsList&,
clang::StoredDeclsList>'
/usr/obj/usr/src/tmp/usr/include/c++/v1/utility:269:77: required by
substitution of 'template<class _U1, class _U2> std::__1::pair<_T1,
_T2>::pair(const std::__1::pair<_U1, _U2>&, typename
std::__1::enable_if<(std::__1::is_convertible<const _U1&, _T1>::value &&
std::__1::is_convertible<const _U2&, _T2>::value)>::type*) [with _U1 =
clang::DeclarationName; _U2 = clang::StoredDeclsList]'
/usr/obj/usr/src/tmp/usr/include/c++/v1/utility:491:69: required from
'std::__1::pair<typename std::__1::__make_pair_return<_Tp>::type, typename
std::__1::__make_pair_return<_T2>::type> std::__1::make_pair(_T1&&, _T2&&)
[with _T1 = clang::DeclarationName&; _T2 = clang::StoredDeclsList; typename
std::__1::__make_pair_return<_T2>::type = clang::StoredDeclsList; typename
std::__1::__make_pair_return<_Tp>::type = clang::DeclarationName]'
/usr/src/lib/clang/libclangast/../../../contrib/llvm/tools/clang/lib/AST/DeclBase.cpp:1313:59:
required from here
/usr/obj/usr/src/tmp/usr/include/c++/v1/type_traits:881:87: error: use of
deleted function 'constexpr clang::StoredDeclsList::StoredDeclsList(const
clang::StoredDeclsList&)'
sizeof(__is_convertible_imp::__test<_T2>(__is_convertible_imp::__source<_T1>()))
== 1
^
In file included from
/usr/src/lib/clang/libclangast/../../../contrib/llvm/tools/clang/lib/AST/DeclBase.cpp:20:0:
/usr/src/lib/clang/libclangast/../../../contrib/llvm/tools/clang/include/clang/AST/DeclContextInternals.h:32:8:
note: 'constexpr clang::StoredDeclsList::StoredDeclsList(const
clang::StoredDeclsList&)' is implicitly declared as deleted because
'clang::StoredDeclsList' declares a move constructor or move assignment
operator
struct StoredDeclsList {
^
Apparently, gcc concludes that 1) it requires a copy constructor for
StoredDeclsList, and 2) the copy constructor is deleted because StoredDeclsList
declares a move constructor. Clang obviously has no problem compiling this
code.
A minimal test case is as follows:
#include <utility>
struct Foo {
Foo() {}
Foo(Foo &&RHS) {}
};
void pairtest(int i)
{
auto p1 = std::make_pair(i, Foo());
}
Compiling this with gcc 4.9.1, and using libc++ trunk r230867 as headers,
results in a similar error:
$ g++49 -std=c++11 -I/share/dim/src/libcxx/trunk/include -c pairtest.cpp
In file included from /share/dim/src/libcxx/trunk/include/__tuple:16:0,
from /share/dim/src/libcxx/trunk/include/utility:157,
from pairtest.cpp:1:
/share/dim/src/libcxx/trunk/include/type_traits: In instantiation of 'struct
std::__1::__is_convertible<const Foo&, Foo, 0u, 0u>':
/share/dim/src/libcxx/trunk/include/type_traits:949:62: required from 'struct
std::__1::is_convertible<const Foo&, Foo>'
/share/dim/src/libcxx/trunk/include/utility:274:77: required by substitution
of 'template<class _U1, class _U2> std::__1::pair<_T1, _T2>::pair(const
std::__1::pair<_U1, _U2>&, typename
std::__1::enable_if<(std::__1::is_convertible<const _U1&, _T1>::value &&
std::__1::is_convertible<const _U2&, _T2>::value)>::type*) [with _U1 = int; _U2
= Foo]'
pairtest.cpp:10:36: required from here
/share/dim/src/libcxx/trunk/include/type_traits:887:87: error: use of deleted
function 'constexpr Foo::Foo(const Foo&)'
sizeof(__is_convertible_imp::__test<_T2>(__is_convertible_imp::__source<_T1>()))
== 1
^
pairtest.cpp:3:8: note: 'constexpr Foo::Foo(const Foo&)' is implicitly declared
as deleted because 'Foo' declares a move constructor or move assignment
operator
struct Foo {
^
In file included from /share/dim/src/libcxx/trunk/include/__tuple:16:0,
from /share/dim/src/libcxx/trunk/include/utility:157,
from pairtest.cpp:1:
/share/dim/src/libcxx/trunk/include/type_traits:851:28: error: initializing
argument 1 of 'char std::__1::__is_convertible_imp::__test(_Tp) [with _Tp =
Foo]'
template <class _Tp> char __test(_Tp);
^
The question is whether this is a libc++ problem or a gcc problem.
[1]
<a href="https://jenkins.freebsd.org/job/FreeBSD_HEAD_external_toolchain_gcc/6/console">https://jenkins.freebsd.org/job/FreeBSD_HEAD_external_toolchain_gcc/6/console</a></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>