LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 32147 - shared_ptr's converting ctor from unique_ptr is incorrectly constrained.
Summary: shared_ptr's converting ctor from unique_ptr is incorrectly constrained.
Status: RESOLVED FIXED
Alias: None
Product: libc++
Classification: Unclassified
Component: All Bugs (show other bugs)
Version: unspecified
Hardware: PC Windows NT
: P enhancement
Assignee: Eric Fiselier
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-03-05 17:30 PST by Eric Fiselier
Modified: 2021-04-08 22:12 PDT (History)
3 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Fiselier 2017-03-05 17:30:22 PST
Libc++ incorrectly rejects the following code.

Reproducer from stack overflow:

// clang++ -std=c++14 test.cpp
#include <memory>

int main() {
    auto up = std::unique_ptr<int[]>(new int[5]{});
    auto sp = std::shared_ptr<int>(std::move(up));
}

I'm not yet 100% sure this is the behavior required be the C++17 standard, but It needs to be investigated and libc++ is most likely wrong.
Comment 1 Eric Fiselier 2017-03-05 20:13:06 PST
So both C++11 and C++14 seem to allow this, but it appears to be forbidden in C++17 after applying p0414r2.
Comment 2 Zoe Carver 2021-04-08 22:12:19 PDT
Fixed by https://reviews.llvm.org/D80882.