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

            Bug ID: 43470
           Summary: shared_ptr<T[]> doesn't work as c++17 says it should.
           Product: libc++
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]

Consider this simple code:

#include <memory>

const uint32_t* start(std::shared_ptr<const uint32_t[]> smart_array) {
    return smart_array.get();
}

This compiles when using libstdc++ : https://godbolt.org/z/cKHZnl

But not under libc++ : https://godbolt.org/z/pDGSS5

The error I get is:

cannot initialize return object of type 'const uint32_t *' (aka 'const unsigned
int *') with an rvalue of type 'std::__1::shared_ptr<unsigned int
const[]>::element_type *' (aka 'unsigned int const (*)[]')

    return smart_array.get();

           ^~~~~~~~~~~~~~~~~

And speaking of element_type, that may be the fundamental underlying problem. 
In C++17, the type referred to by shared_ptr<T>::element_type changed from:

  T

to:

  std::remove_extent_t<T>

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

Reply via email to