Debian Codegraph @

gcc/testsuite/g++.dg/warn/Wmismatched-new-delete-8.C

raw
1 /* PR tree-optimization/109804 */
2 /* { dg-do compile { target c++11 } } */
3 /* { dg-options "-Wall" } */
4
5 /* Here we used to ICE in new_delete_mismatch_p because
6 we didn't handle unnamed types from the demangler (DEMANGLE_COMPONENT_UNNAMED_TYPE). */
7
8 template <typename T, typename ARGS>
9 static inline T * construct_at(void *at, ARGS && args)
10 {
11 struct Placeable : T
12 {
13 Placeable(ARGS && args) : T(args) { }
14 void * operator new (__SIZE_TYPE__, void *ptr) { return ptr; }
15 void operator delete (void *, void *) { }
16 };
17 return new (at) Placeable(static_cast<ARGS &&>(args));
18 }
19 template <typename MT>
20 struct Reconstructible
21 {
22 char _space[sizeof(MT)];
23 Reconstructible() { }
24 };
25 template <typename MT>
26 struct Constructible : Reconstructible<MT>
27 {
28 Constructible(){}
29 };
30 struct A { };
31 struct B
32 {
33 Constructible<A> a { };
34 B(int) { }
35 };
36 Constructible<B> b { };
37 void f()
38 {
39 enum { ENUM_A = 1 };
40 enum { ENUM_B = 1 };
41 construct_at<B>(b._space, ENUM_B);
42 }