1 /* PR c++/100876 - -Wmismatched-new-delete should either look through
2 or ignore placement new
4 { dg-options "-O0 -Wall -Wno-array-bounds" } */
6 inline void* operator new (__SIZE_TYPE__, void *p) { return p; }
7 inline void* operator new[] (__SIZE_TYPE__, void *p) { return p; }
9 void* nowarn_placement_new_memset ()
12 void *p = __builtin_malloc (sizeof (S));
14 __builtin_memset (q, 0, sizeof (S));
18 void* warn_placement_new_memset ()
21 void *p = __builtin_malloc (sizeof (S));
23 __builtin_memset (q, 0, sizeof (S) + 1); // { dg-warning "\\\[-Wstringop-overflow" }
27 void* nowarn_placement_new_array_strncpy (const char *s)
29 void *p = __builtin_malloc (5);
30 char *q = new (p) char[5];
31 __builtin_strncpy (q, s, 5);
36 void* warn_placement_new_array_strncpy (const char *s)
38 void *p = __builtin_malloc (4);
39 char *q = new (p) char[5];
40 __builtin_strncpy (q, s, 5); // { dg-warning "\\\[-Wstringop-overflow" }