1 // PR c++/71913
2 // { dg-do link { target c++11 } }
3 
4 void* operator new(decltype(sizeof(1)), void* p) { return p; }
5 
6 struct IndirectReturn {
IndirectReturnIndirectReturn7   IndirectReturn() {}
8   // Undefined so we get a link error if the indirect return value is copied
9   IndirectReturn(const IndirectReturn&);
10   IndirectReturn& operator=(const IndirectReturn&) = delete;
~IndirectReturnIndirectReturn11   ~IndirectReturn() {}
12 };
13 
foo()14 IndirectReturn foo() { return IndirectReturn(); }
15 
bar(void * ptr)16 void bar(void* ptr) {
17   new (ptr) IndirectReturn(foo());
18 }
19 
20 alignas (alignof (IndirectReturn))
21 unsigned char c[sizeof(IndirectReturn)];
22 
main()23 int main()
24 {
25   bar(c);
26 }
27