summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/pr91570.c
blob: 03f268619e972859a0032aaa208c837fbe0c219d (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
/* PR tree-optimization/91570 - ICE in get_range_strlen_dynamic on
   a conditional of two strings
   { dg-do compile }
   { dg-options "-O2 -Wall" } */

extern char a[], b[];

/* Test case from comment #0 on the bug.  */

void comment_0 (int i)
{
  a[0] = 0;
  b[0] = '1';

  const char *p = i ? b : a;

  if (__builtin_snprintf (0, 0, "%s", p) < 4)
    __builtin_abort ();
}


/* Test case from comment #2 on the bug.  */

void comment_2 (char *s)
{
  char *t = __builtin_strrchr (s, '/');
  __builtin_strcat (s, ".SIF");
  t = t ? t : s;
  __builtin_printf ("%s", t);
}