<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - shared_ptr<T[]> doesn't work as c++17 says it should."
   href="https://bugs.llvm.org/show_bug.cgi?id=43470">43470</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>shared_ptr<T[]> doesn't work as c++17 says it should.
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libc++
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>All Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>jorg.brown@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, mclow.lists@gmail.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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++ : <a href="https://godbolt.org/z/cKHZnl">https://godbolt.org/z/cKHZnl</a>

But not under libc++ : <a href="https://godbolt.org/z/pDGSS5">https://godbolt.org/z/pDGSS5</a>

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></pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>