aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/pr95768.C
blob: d34d513313469faa1dd9fdfb630ad4ec91700c07 (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
29
30
31
32
/* PR c++/95768 - pretty-printer ICE on -Wuninitialized with allocated storage
   { dg-do compile }
   { dg-options "-O2 -Wall -Wno-array-bounds" } */

extern "C" void *malloc (__SIZE_TYPE__);

struct f
{
  int i;
  static int e (int);
  void operator= (int) { e (i); }
};

struct m {
  int i;
  f length;
};

struct n {
  m *o() { return (m *)this; }
};

struct p {
  n *header;
  p () {
    header = (n *)malloc (0);
    m b = *header->o();       // { dg-warning "\\\[-Wuninitialized" }
    b.length = 0;
  }
};

void detach2() { p(); }