1 // PR c++/71306 - bogus -Wplacement-new with an array element
2 // { dg-do compile }
3 // { dg-options "-Wplacement-new" }
4 
new(__SIZE_TYPE__,void * p)5 void* operator new (__SIZE_TYPE__, void *p) { return p; }
6 
7 struct S64 { char c [64]; };
8 
9 S64 s2 [2];
10 S64* ps2 [2];
11 S64* ps2_2 [2][2];
12 
13 void* pv2 [2];
14 
f()15 void f ()
16 {
17   char a [2][sizeof (S64)];
18 
19   new (a) S64;
20   new (a [0]) S64;
21   new (a [1]) S64;
22 
23   // Verify there is no warning with buffers of sufficient size.
24   new (&s2 [0]) S64;
25   new (&s2 [1]) S64;
26 
27   // ..and no warning with pointers to buffers of unknown size.
28   new (ps2 [0]) S64;
29   new (ps2 [1]) S64;
30 
31   // But a warning when using the ps2_2 array itself as opposed
32   // to the pointers it's elements might point to.
33   new (ps2_2 [0]) S64;	// { dg-warning "placement new" }
34   new (ps2_2 [1]) S64;	// { dg-warning "placement new" }
35 
36   // ..and no warning again with pointers to buffers of unknown
37   // size.
38   new (pv2 [0]) S64;
39   new (pv2 [1]) S64;
40 }
41