summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/tree-ssa/pr19637.C
blob: 2d1dcceba42f59b286e210d8e1086ef730b845fa (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
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-dom1" } */

#include <new>

struct Foo {
  Foo() { i[0] = 1; }
  int i[2];
};

int foo_char(void)
{
  int i[2];
  new (reinterpret_cast<char *>(i)) Foo();
  return reinterpret_cast<Foo *>(i)->i[0];
}

int foo_void(void)
{
  int i[2];
  new (reinterpret_cast<void *>(i)) Foo();
  return reinterpret_cast<Foo *>(i)->i[0];
}

int foo_void_offset(void)
{
  int i[2];
  new (reinterpret_cast<void *>(&i[0])) Foo();
  return reinterpret_cast<Foo *>(&i[0])->i[0];
}

/* { dg-final { scan-tree-dump-times "return 1;" 3 "dom1" } } */
/* { dg-final { cleanup-tree-dump "dom1" } } */