<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </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 --- - basic_string does not respect NullablePointer requirements of the allocator's pointer"
   href="http://llvm.org/bugs/show_bug.cgi?id=20508">20508</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>basic_string does not respect NullablePointer requirements of the allocator's pointer
          </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>tkoeppe@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu, mclow.lists@gmail.com
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=12843" name="attach_12843" title="Compilation failure of basic_string with fancy pointer allocator">attachment 12843</a> <a href="attachment.cgi?id=12843&action=edit" title="Compilation failure of basic_string with fancy pointer allocator">[details]</a></span>
Compilation failure of basic_string with fancy pointer allocator

I'm attaching a complete example, but the problem is easily described:

The pointer type, std::allocator_traits<A>::pointer, is not required to be
trivially constructible. In fact, it is *impossible* for this type to be
trivially constructible if it is a class type, since it must value-initialize
to the null value.

However, the current implementation of basic_string assumes that the pointer
type is trivially constructible (since it puts the type into a union without
any user-provided constructors). This makes it impossible to use basic_string
with fancy pointers.

I haven't thought too much about a solution, but I think that adding suitable
constructors to the SSO union __rep and to the type __long would make this work
and wouldn't be too invasive a change.</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>