aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common/asan/pr71480.c
blob: c23ea5385b490916882bb9a8c9076e2c317d7556 (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
42
/* { dg-do run } */

__attribute__ ((noinline, noclone)) int
foo (char *c)
{
  asm volatile ("" : : "r" (c) : "memory");
  return 1;
}

__attribute__ ((noinline, noclone)) void
bar (char *c)
{
  asm volatile ("" : : "r" (c) : "memory");
}

int main ()
{
  char tpl[20] = "/tmp/test.XXXXXX";
  char tpl2[20] = "/tmp/test.XXXXXX";
  int fd = foo (tpl);
  int fd2 = foo (tpl2);
  if (fd == -1)
    {
      if (fd2 != -1)
	 bar (tpl2);
      return 1;
    }

  if (fd2 == -1)
    return 1;

  bar (tpl);
  bar (tpl2);

  if (__builtin_strcmp (tpl, "/tmp/test.XXXXXX") != 0)
    return 1;

  if (__builtin_strcmp (tpl, tpl2) != 0)
    return 1;

   return 0;
}