aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp1z/launder6.C
blob: e92b02cd5e2aefda5d4b43dfaa80d0c4ca7ae26c (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
// { dg-do run { target c++11 } }
// { dg-additional-options "-O2" }
// { dg-additional-sources "launder6.cc" }
// { dg-skip-if "requires hosted libstdc++ for cassert" { ! hostedlib } }
#include <cassert>
#include "launder6.h"

namespace std
{
  template <typename T>
  T *
  launder (T *p)
  {
    return __builtin_launder (p);
  }
}

int
main ()
{
  int x = 42;
  B b{{x}};
  f(b);
  assert(std::launder(&b.a)->x == 666);
}