Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<iterator> free cbegin/cend crbegin/crend erroneous ADL begin/end rbegin/rend #29297

Closed
ecatmur opened this issue Aug 10, 2016 · 2 comments
Closed
Assignees
Labels
bugzilla Issues migrated from bugzilla libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

Comments

@ecatmur
Copy link

ecatmur commented Aug 10, 2016

Bugzilla Link 28927
Resolution FIXED
Resolved on Aug 10, 2016 15:05
Version 3.9
OS Windows NT
CC @mclow

Extended Description

#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

@ecatmur
Copy link
Author

ecatmur commented Aug 10, 2016

assigned to @mclow

@mclow
Copy link
Contributor

mclow commented Aug 10, 2016

Fixed in commit 278282

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

No branches or pull requests

2 participants