summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp1z/aligned-new2.C
blob: fe159692b3bee142aa381a80d40a518b4ec0e72f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// { dg-options -std=c++1z }
// { dg-do run }

#include <new>

struct alignas(64) A {
  int i;
  A() { throw 42; }
};
struct B { int i; } b;

void *operator new (std::size_t s, std::align_val_t a, B b)
{
  return operator new (s, a);
}

bool deleted = false;
void operator delete (void *p, std::align_val_t, B)
{
  deleted = true;
}

int main()
{
  try {
    A *p = new (b) A;
    __builtin_abort ();
  } catch (...) {}
  if (!deleted)
    __builtin_abort ();
}