summaryrefslogtreecommitdiff
path: root/support/regression/tests/gcc-torture-execute-20050826-1.c
blob: 717d6cc9471bb2fe3573472891782b42a5338f48 (plain) (blame)
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
/*
   20050826-1.c from the execute part of the gcc torture suite.
 */

#include <testfwk.h>

#ifdef __SDCC
#pragma std_c99
#endif

#include <string.h>

#if defined __SDCC_pdk14
#define SIZE 8     // the available memory is limited
#elif defined __SDCC_MODEL_SMALL || defined __SDCC_MODEL_MEDIUM || defined __SDCC_pdk15
#define SIZE 64     // the available memory is limited
#else
#define SIZE 2048
#endif

/* PR rtl-optimization/23561 */

struct A
{
  char a1[1];
  char a2[5];
  char a3[1];
  char a4[SIZE - 7];
} a;

void
bar (struct A *x)
{
  size_t i;
  ASSERTFALSE (memcmp (x, "\1HELLO\1", sizeof "\1HELLO\1"));
  for (i = 0; i < sizeof (x->a4); i++)
    ASSERTFALSE (x->a4[i]);
}

int
foo (void)
{
  memset (&a, 0, sizeof (a));
  a.a1[0] = 1;
  memcpy (a.a2, "HELLO", sizeof "HELLO");
  a.a3[0] = 1;
  bar (&a);
  return 0;
}

void
testTortureExecute (void)
{
  foo ();
}