Allow placement new array test to consume extra bytes as specified by the standard.

llvm-svn: 273342
This commit is contained in:
Eric Fiselier 2016-06-22 00:32:28 +00:00
parent 97e0ba02fd
commit 0df0296974
1 changed files with 8 additions and 4 deletions

View File

@ -22,9 +22,13 @@ struct A
int main()
{
char buf[3*sizeof(A)];
const std::size_t Size = 3;
// placement new might require additional space.
const std::size_t ExtraSize = 64;
char buf[Size*sizeof(A) + ExtraSize];
A* ap = new(buf) A[3];
assert((char*)ap == buf);
assert(A_constructed == 3);
A* ap = new(buf) A[Size];
assert((char*)ap >= buf);
assert((char*)ap < (buf + ExtraSize));
assert(A_constructed == Size);
}