Skip to content

[libc++] __wrap_iter<T> can hijack operator+/operator< via ADL #107747

Closed as not planned
@MitalAshok

Description

@MitalAshok

With two T* pointers, </- always has the built-in meaning. But __wrap_iter has a T* template argument so that adds T's namespace as an associated namespace.

In particular, with nasty_char (from https://github.com/llvm/llvm-project/blob/main/libcxx/test/support/nasty_string.h),

https://godbolt.org/z/YT3MvPGd9:

static_assert(std::random_access_iterator<nasty_char*>);
static_assert(!std::random_access_iterator<std::__wrap_iter<nasty_char*>>);
static_assert(!std::random_access_iterator<nasty_string::iterator>);

Shouldn't use user-overloads for non-pointer types, like template<typename T> friend bool operator<(T, T) with T = __wrap_iter<my_random_access_iterator>, either.

Metadata

Metadata

Assignees

No one assigned

    Labels

    invalidResolved as invalid, i.e. not a buglibc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions