<html>
<head>
<base href="https://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 --- - <iterator> free cbegin/cend crbegin/crend erroneous ADL begin/end rbegin/rend"
href="https://llvm.org/bugs/show_bug.cgi?id=28927">28927</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td><iterator> free cbegin/cend crbegin/crend erroneous ADL begin/end rbegin/rend
</td>
</tr>
<tr>
<th>Product</th>
<td>libc++
</td>
</tr>
<tr>
<th>Version</th>
<td>3.9
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</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>ed@catmur.co.uk
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, mclow.lists@gmail.com
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>#include <iterator>
#include <type_traits>
struct S {};
int begin(S);
template<class T> std::true_type has_cbegin(decltype(std::cbegin(T{})));
template<class T> std::false_type has_cbegin(...);
static_assert(!decltype(has_cbegin<S>(0))::value);
Libc++ cbegin etc. call the corresponding non-const free functions unqualified,
so performing ADL:
template <class _Cp>
inline _LIBCPP_INLINE_VISIBILITY
auto cbegin(const _Cp& __c) -> decltype(begin(__c))
{
return begin(__c);
}
This is contrary to [iterator.range] (per C++14 and up to n6406) which
specifies that std::begin is called qualified. libstdc++ gets this right. Also
correct in libc++ <iterator> synopsis.
From:
<a href="http://stackoverflow.com/questions/38878454/clang-vs-gcc-stdcrbegin-with-boostiterator-range">http://stackoverflow.com/questions/38878454/clang-vs-gcc-stdcrbegin-with-boostiterator-range</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>