<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 - Calling array new with a negative size should be checked in C++14 mode"
   href="https://bugs.llvm.org/show_bug.cgi?id=35573">35573</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Calling array new with a negative size should be checked in C++14 mode
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </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>C++14
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>t.p.northover@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>When emitting code for a new array expression we check whether the array size
is negative in C++98 and C++11 mode, but not from C++14 onwards. E.g.

char *foo(int a) {
  return new char[a];
}

$ clang++ tmp.cpp -std=c++11 -S -o- -emit-llvm -Os
define noalias nonnull i8* @_Z3fooi(i32 %a) local_unnamed_addr #0 {
entry:
  %0 = sext i32 %a to i64
  %1 = icmp sgt i64 %0, -1
  %2 = select i1 %1, i64 %0, i64 -1
  %call = tail call i8* @_Znam(i64 %2) #2
  ret i8* %call
}

$ clang++ tmp.cpp -std=c++14 -S -o- -emit-llvm -Os
define noalias nonnull i8* @_Z3fooi(i32 %a) local_unnamed_addr #0 {
entry:
  %conv = sext i32 %a to i64
  %call = tail call i8* @_Znam(i64 %conv) #2
  ret i8* %call
}</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>