Debian Codegraph @

gcc/testsuite/g++.dg/opt/pr103984.C

raw
1 // PR middle-end/103984
2 // { dg-do compile { target c++11 } }
3 // { dg-options "-O2 -Wuninitialized" }
4
5 struct A {
6 char *a;
7 char b[4];
8 A ();
9 A (const A &);
10 A (const char *);
11 A (const char *, const char *);
12 [[gnu::always_inline]] ~A () { if (a != b) delete a; }
13 };
14 struct B {
15 const char *c = nullptr;
16 const char *d = nullptr;
17 A qux () const { return A (c, d); }
18 B (const char *x) : c(x), d(x) { d += __builtin_strlen (x); }
19 B (const B &x) { c = x.c; d = x.d; }
20 };
21 struct C { A e; int f; };
22 extern int baz (B);
23 void bar (C &&);
24
25 void
26 foo (char **x)
27 {
28 const A g ("foo");
29 const B h = x[0];
30 bar (C { h.qux (), baz (h) });
31 }