Debian Codegraph @

gcc/testsuite/g++.dg/tree-ssa/pr107206.C

raw
1 // { dg-do compile }
2 // { dg-require-effective-target c++17 }
3 // { dg-options "-O -Wuninitialized" }
4
5 #include <optional>
6 struct X {
7 X() = default;
8 X(X const& r) : i(r.i) {}
9 int i;
10 };
11 struct Y {
12 Y() : x() {}
13 X x;
14 std::optional<int> o;
15 };
16 struct Z {
17 Y y;
18 explicit Z(Y y) : y(y) {}
19 };
20 void f(Y const&);
21 void test() {
22 Y const y;
23 Z z(y);
24 z.y.o = 1;
25 auto const w = z;
26 f(w.y);
27 }