summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/torture/pr49079.c
blob: 1b53d3c3126a8a69865402021cb689a5c1333a67 (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
/* { dg-do run } */

extern void abort (void);

struct Ustr
{
  unsigned char data[1];
};

static unsigned int
ustr_xi__embed_val_get(const unsigned char *data)
{
  return (unsigned int)data[0];
}

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

static unsigned int
ustr_len(const struct Ustr *s1)
{
  return ustr_xi__embed_val_get(s1->data + 1 + zero());
}

int
main()
{
  if (ustr_len (((struct Ustr *) "\x01" "\x0002" "s2")) != 2)
    abort ();

  return 0;
}