summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp1y/constexpr-empty2.C
blob: 9768b89904edfd0afc183effd74544606c810d00 (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
28
// { dg-do compile { target c++14 } }
// { dg-additional-options -fno-elide-constructors }

struct A
{
  constexpr A(int) { }
};

struct B: A {
  constexpr B(int i): A(i) { }
  constexpr B(const B& b): A(b) { }
};

struct C {
  B b;
  constexpr C(int i): b(i) { }
  constexpr C(const C&c): b(c.b) {}
};

constexpr int f()
{
  C b1{42};
  C b2{b1};
  b2.b;
  return 42;
}

constexpr int i = f();