[llvm-bugs] [Bug 42021] New: get function of shared_ptr depends on ampersand overload

via llvm-bugs llvm-bugs at lists.llvm.org
Sat May 25 13:08:59 PDT 2019


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

            Bug ID: 42021
           Summary: get function of shared_ptr depends on ampersand
                    overload
           Product: libc++
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: alfredo.correa at gmail.com
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com

get is currently implemented as 

    _Tp* get() _NOEXCEPT {return &__data_.second();}

This dependency on the behavior of ampersand is artificial (because second was
choosen to be a reference) and it is not even guaranteed to return something of
type _Tp*.

A more correct implementation would be

    _Tp* get() _NOEXCEPT {return std::addressof(__data_.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/20190525/c36e4241/attachment.html>


More information about the llvm-bugs mailing list