repo.or.cz
/
official-gcc.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
2018-11-07 Richard Biener <rguenther@suse.de>
[official-gcc.git]
/
gcc
/
testsuite
/
g++.dg
/
cpp1z
/
launder4.C
blob
3a65eb27f2e86958afca4265f683a11d215e21be
1
// { dg-do run { target c++11 } }
2
// { dg-additional-options "-O2" }
3
4
#include <cassert>
5
6
void *
7
operator new (decltype (sizeof (0)), void *p)
8
{
9
return p;
10
}
11
12
namespace std
13
{
14
template <typename T>
15
T *
16
launder (T *p)
17
{
18
return __builtin_launder (p);
19
}
20
}
21
22
struct A
23
{
24
int& x;
25
};
26
27
struct B
28
{
29
A a;
30
};
31
32
int
33
main ()
34
{
35
int x = 42;
36
B b{{x}};
37
int y = 666;
38
new (&b.a) A{y};
39
assert(std::launder(&b.a)->x == 666);
40
}