summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.c-torture/execute/20011024-1.c
blob: 5b871bbb9ec7c7852ab9d49f92774a867d4e1505 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/* Test whether store motion recognizes pure functions as potentially reading
   any memory.  */

typedef __SIZE_TYPE__ size_t;
extern void *memcpy (void *dest, const void *src, size_t n);
extern size_t strlen (const char *s);
extern int strcmp (const char *s1, const char *s2) __attribute__((pure));

char buf[50];

static void foo (void)
{
  if (memcpy (buf, "abc", 4) != buf) abort ();
  if (strcmp (buf, "abc")) abort ();
  memcpy (buf, "abcdefgh", strlen ("abcdefgh") + 1);
}

int main (void)
{
  foo ();
  return 0;
}