aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.target/i386/pr60700.c
blob: 5428f3616237ebbbf21dfa6dc61f9bd0b0b9a9e2 (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/* PR rtl-optimization/60700 */
/* { dg-do run { target ia32 } } */
/* { dg-options "-O3 -march=i686" } */

int
__attribute__((noinline))
foo (void)
{
  return 0;
}

void *g = (void *)1;

struct st {
  char data[36]; /* must be greater than 32.  */
};

int
__attribute__((noinline))
repro(struct st **out)
{
  int status = 0;

  *out = 0;

  status = foo();
  if (status != 0) {
    return status;
  }

  if (0 == g) {
    status = 999;
    return status;
  }

  *out = (struct st *)__builtin_malloc(sizeof(struct st));
  if (0 == *out) {
    status = 42;
    return status;
  }

  __builtin_memset(*out, 0, sizeof(struct st));

  return status;
}

int
main ()
{
  struct st *p;
  int ret = repro (&p);
  unsigned int i;

  for (i = 0; i < sizeof (p->data)/sizeof (p->data[0]); i++)
    if (p->data[i] != 0)
      __builtin_abort ();

  return ret;
}