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

            Bug ID: 27556
           Summary: shared_ptr issues when allocator/deleter have throwing
                    move constructor
           Product: libc++
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]
    Classification: Unclassified

There seems to be an issue in the shared_ptr implementation if the move
constructor of the deleter and/or allocator throw an exception. The standard
only guarantees that the copy constructor of the allocator and deleter may not
throw, nothing in there talks about move constructors.

In <memory>, line 4185, the allocator and deleter get passed into the _CntrlBlk
aka __shared_ptr_pointer by copy, which is fine and will not throw (note:
instead of always copying, we could use std::move_if_noexcept here).
The __shared_ptr_pointer constructor hands off the deleter and allocator into
the __compressed_pair by unconditional move (!). This can throw, and at line
4191, __d could already be moved-from or partially moved-from.

I think these calls to std::move should be replaced with std::move_if_noexcept.
There are more move constructors being invoked inside __compressed_pair, which
will also need to get looked at.

Line numbers refer to SVN revision 267901.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to