<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 --- - placement new null checks should be optimized away"
   href="http://llvm.org/bugs/show_bug.cgi?id=22556">22556</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>placement new null checks should be optimized away
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.5
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </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>LLVM Codegen
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>vlovich@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Although the C++ standard address the placement-new/nullptr issue in C++17, it
would seem like the optimizer should be able to optimize away the cost
regardless, at least for vector.

Although placement new could be being called on a nullptr, it will be called
with p[i] where i is some value in [0, size() - 1].

Except for the p[0] case, p[x] where x is in [1, size() - 1] cannot be a
nullptr since pointer arithmetic is undefined behaviour for overflow.

Test-case code:
<a href="https://pastebin.mozilla.org/8625250">https://pastebin.mozilla.org/8625250</a>

More information:
<a href="http://www.reddit.com/r/cpp/comments/2v3viw/cs_placementnew_prevents_optimalcode_generation/">http://www.reddit.com/r/cpp/comments/2v3viw/cs_placementnew_prevents_optimalcode_generation/</a></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>