<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 --- - [C++14] new expression should cause compilation error if expression in a noptr-new-declarator is erroneous"
   href="http://llvm.org/bugs/show_bug.cgi?id=22845">22845</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[C++14] new expression should cause compilation error if expression in a noptr-new-declarator is erroneous
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </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>C++14
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>kariya_mitsuru@hotmail.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>Created <span class=""><a href="attachment.cgi?id=14009" name="attach_14009" title="clang++ -v">attachment 14009</a> <a href="attachment.cgi?id=14009&action=edit" title="clang++ -v">[details]</a></span>
clang++ -v

The both sample codes below should cause compilationn error but they are
compiled successfully.

========================== sample code ==========================
int main()
{
    constexpr int i = -1;
    int* p = new int[i];
    delete[] p;
}
========================== sample code ==========================
cf. <a href="http://melpon.org/wandbox/permlink/TLTsz1iiAVM8DbV0">http://melpon.org/wandbox/permlink/TLTsz1iiAVM8DbV0</a>

========================== sample code ==========================
int main()
{
    constexpr int i = 1;
    int* p = new int[i]{ 1, 2 };
    delete[] p;
}
========================== sample code ==========================
cf. <a href="http://melpon.org/wandbox/permlink/mEhdOsjtC2ztiFbb">http://melpon.org/wandbox/permlink/mEhdOsjtC2ztiFbb</a>


Tthe C++14 standard 5.3.4[expr.new]/p.7 says,

  The expression in a noptr-new-declarator is erroneous if:

    --- the expression is of non-class type and its value before converting to
        std::size_t is less than zero;

    ...

    --- the new-initializer is a braced-init-list and the number of array
elements
        for which initializers are provided (including the terminating '\0' in
a
        string literal (2.13.5)) exceeds the number of elements to initialize.

  If the expression, after converting to std::size_t, is a core constant
expression
  and the expression is erroneous, the program is ill-formed.  ...


So, I think that the sample codes above should cause compilation error.</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>