[LLVMbugs] [Bug 22845] New: [C++14] new expression should cause compilation error if expression in a noptr-new-declarator is erroneous

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun Mar 8 11:06:39 PDT 2015


http://llvm.org/bugs/show_bug.cgi?id=22845

            Bug ID: 22845
           Summary: [C++14] new expression should cause compilation error
                    if expression in a noptr-new-declarator is erroneous
           Product: clang
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++14
          Assignee: unassignedclangbugs at nondot.org
          Reporter: kariya_mitsuru at hotmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 14009
  --> http://llvm.org/bugs/attachment.cgi?id=14009&action=edit
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. http://melpon.org/wandbox/permlink/TLTsz1iiAVM8DbV0

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


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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150308/24370dde/attachment.html>


More information about the llvm-bugs mailing list