[llvm-bugs] [Bug 44398] New: Unqualified calls of std::ref lead to ADL issues

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Dec 28 18:46:54 PST 2019


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: unassignedclangbugs at nondot.org
          Reporter: arthur.j.odwyer at gmail.com
                CC: llvm-bugs at lists.llvm.org, mclow.lists at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20191229/5f7f0447/attachment.html>


More information about the llvm-bugs mailing list