blob: 0a9978ca6615046e149702af04ecf422873bb459 (
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
|
// PR c++/71913
// { dg-do link { target c++11 } }
void* operator new(unsigned long, void* p) { return p; }
struct IndirectReturn {
IndirectReturn() {}
// Undefined so we get a link error if the indirect return value is copied
IndirectReturn(const IndirectReturn&);
IndirectReturn& operator=(const IndirectReturn&) = delete;
~IndirectReturn() {}
};
IndirectReturn foo() { return IndirectReturn(); }
void bar(void* ptr) {
new (ptr) IndirectReturn(foo());
}
alignas (alignof (IndirectReturn))
unsigned char c[sizeof(IndirectReturn)];
int main()
{
bar(c);
}
|