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

            Bug ID: 44398
           Summary: Unqualified calls of std::ref lead to ADL issues
           Product: libc++
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangb...@nondot.org
          Reporter: arthur.j.odw...@gmail.com
                CC: llvm-bugs@lists.llvm.org, mclow.li...@gmail.com

https://bugs.llvm.org/show_bug.cgi?id=20092 is related, but for `get` instead
of `ref`.

// https://gcc.godbolt.org/z/8VfprT
#include <functional>

struct S {
    friend void ref(S);
    friend void deref(S);
};
int main() {
    S s;
    auto rw = std::ref(s);    // OK
    auto rw2 = std::ref(rw);  // massive error spew
}


Currently <__functional_base> has

    template <class _Tp>
    inline _LIBCPP_INLINE_VISIBILITY
    reference_wrapper<_Tp>
    ref(reference_wrapper<_Tp> __t) _NOEXCEPT
    {
        return ref(__t.get());
    }

It should have

        return _VSTD::ref(__t.get());

or simply (LWG 3146)

        return __t;

There's also an unqualified ADL `ref` in <memory>:

// https://gcc.godbolt.org/z/EHw3Gy
#include <memory>
#include <utility>

struct D {
    void operator()(int *) const;
    friend void ref(D);
    friend void deref(D);
};
int main() {
    D d;
    std::unique_ptr<int, D&> u(nullptr, d);
    std::shared_ptr<int> s = std::move(u);
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to