summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp1z/aligned-new9.C
blob: 3fa0ed996bd321ae3cffce16fdf7a9820cbd11d7 (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
// PR c++/102071
// { dg-do run { target c++17 } }
// { dg-additional-options -faligned-new=2 }

#include <new>

int nalign;
void *operator new (std::size_t s, std::align_val_t a)
{
  nalign = (int)a;
  return operator new (s);
}

struct X { ~X(); int c; };

int align = (alignof (X) > alignof (std::size_t)
	     ? alignof (X) : alignof (std::size_t));

int n = 4;

int main()
{
  X *p = new X[n];
  if (nalign != align)
    __builtin_abort ();

  X *p2 = new X;
  if (nalign != alignof (X))
    __builtin_abort ();
}