summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-bogus-escape-3.C
blob: de6b2c477352a7811110abf933888df4a0c7a976 (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
33
34
35
/* { dg-do compile } */
/* { dg-options "-O2 -Wstrict-aliasing" } */

struct Node_base {};

struct Node : Node_base
{
  int data;
};

struct List
{
  Node_base node, *prev;

  List() : prev(&node) { xyz(); }

  void xyz();

  int back() { return static_cast<Node*>(prev)->data; }
};

struct A
{
  virtual ~A();
};

A* foo();

void bar()
{
  List y;
  if (y.back())
    delete foo();
}