https://bugs.llvm.org/show_bug.cgi?id=38300
Bug ID: 38300
Summary: Wrong exception deduction for some forms of placement
new
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: C++
Assignee: unassignedclangb...@nondot.org
Reporter: zhong...@pku.org.cn
CC: dgre...@apple.com, llvm-bugs@lists.llvm.org
clang version 7.0.0 (trunk 337118) rejects the following program:
//--
#include <new>
int n;
static_assert(!noexcept(::new (std::nothrow) int[n]), "");
//--
Further the following program aborts even though it shouldn't:
//---
#include <new>
extern "C" void abort();
void test_too_small(int n) {
new (std::nothrow) int[n]{1,2,3,4};
}
int main()
{
bool f = false;
try {
test_too_small(3);
} catch (...) {
f = true;
}
if (!f)
abort();
}
//---
Rationale: According to [expr.new] p7:
"[..] if the new-initializer is a bracedinit-list for which the number of
initializer-clauses exceeds the number of elements to initialize, no storage
is obtained and the new-expression terminates by throwing an exception of a
type that would match a handler (15.3) of type std::bad_array_new_length
(18.6.2.2)."
I tried g++. It accept both code samples, and the second code sample does not
abort.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs