blob: e52d55fae6809f6ef00a0bd43de480f7d734a55c (
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
|
// PR c++/71913
// { dg-do link { target c++11 } }
void* operator new(decltype(sizeof(1)), 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);
}
|