summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.c-torture/execute/pr42691.c
blob: 7eeee99ec2f5103e8179b68b4c5c3d20a6df314f (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
extern void abort (void);

union _D_rep
{
  unsigned short rep[4];
  double val;
};

int add(double* key, double* table)
{
  unsigned i = 0;
  double* deletedEntry = 0;
  while (1) {
    double* entry = table + i;

    if (*entry == *key)
      break;

    union _D_rep _D_inf = {{ 0, 0, 0, 0x7ff0 }};
    if (*entry != _D_inf.val)
      abort ();

    union _D_rep _D_inf2 = {{ 0, 0, 0, 0x7ff0 }};
    if (!_D_inf2.val)
      deletedEntry = entry;

    i++;
  }
  if (deletedEntry)
    *deletedEntry = 0.0;
  return 0;
}

int main ()
{
  union _D_rep infinit = {{ 0, 0, 0, 0x7ff0 }};
  double table[2] = { infinit.val, 23 };
  double key = 23;
  int ret = add (&key, table);
  return ret;
}