[llvm-bugs] [Bug 28927] New: <iterator> free cbegin/cend crbegin/crend erroneous ADL begin/end rbegin/rend

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Aug 10 09:49:37 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=28927

            Bug ID: 28927
           Summary: <iterator> free cbegin/cend crbegin/crend erroneous
                    ADL begin/end rbegin/rend
           Product: libc++
           Version: 3.9
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: ed at catmur.co.uk
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com
    Classification: Unclassified

#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:
http://stackoverflow.com/questions/38878454/clang-vs-gcc-stdcrbegin-with-boostiterator-range

-- 
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/20160810/1b2b6960/attachment.html>


More information about the llvm-bugs mailing list