[llvm-bugs] [Bug 24890] New: swap(pair& __p) uses & instead of std::addressof

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Sep 21 02:19:00 PDT 2015


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

            Bug ID: 24890
           Summary: swap(pair& __p) uses & instead of std::addressof
           Product: libc++
           Version: 3.7
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: sebastian at theophil.net
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com
    Classification: Unclassified

In lines 386 and 387 of the utility header, std::addressof should be used
instead of &:

    void
    swap(pair& __p) _NOEXCEPT_(__is_nothrow_swappable<first_type>::value &&
                               __is_nothrow_swappable<second_type>::value)
    {
        _VSTD::iter_swap(&first, &__p.first);
        _VSTD::iter_swap(&second, &__p.second);
    }

should be

    void
    swap(pair& __p) _NOEXCEPT_(__is_nothrow_swappable<first_type>::value &&
                               __is_nothrow_swappable<second_type>::value)
    {
        _VSTD::iter_swap(std::addressof(first), std::addressof(__p.first));
        _VSTD::iter_swap(std::addressof(second), std::addressof(__p.second));
    }

-- 
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/20150921/f9a532f4/attachment.html>


More information about the llvm-bugs mailing list