summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/strlenopt-94.c
blob: c2a23d35881239df330cc53462fbca49b6d9fdd1 (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
/* PR tree-optimization/93982 - Assignment incorrectly omitted by
   -foptimize-strlen
   { dg-do run }
   { dg-options "-O2 -Wall" } */

struct A { const char **a; };
const char *buf[5];

__attribute__((noipa)) struct A
foo (char *p)
{
  struct A r = { (const char **) p };
  r.a[0] = "12345678";
  r.a[1] = "";
  r.a[2] = "";
  r.a[3] = "";
  r.a[4] = "";
  return r;
}

int
main ()
{
  struct A r = foo ((char *) &buf[0]);
  if (!r.a[1] || r.a[1][0] != '\0')
    __builtin_abort ();
  return 0;
}