blob: 4997f9b8355b927c5488fbc09ca0fc7d9acbf336 (
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
|
/* PR tree-optimization/43904. */
/* { dg-do run } */
/* { dg-options "-O1 -foptimize-sibling-calls" } */
typedef __SIZE_TYPE__ size_t;
extern void abort(void);
void *memcpy(void *dest, const void *src, size_t n);
void
buggy_init(void *ptr, size_t size)
{
const char *str = "Hello world!";
memcpy(ptr, &str, size);
}
void
expose_bug(void *ptr, size_t size)
{
const char *str;
memcpy(&str, ptr, size);
if (*str != 'H')
abort ();
}
int
main()
{
const char *ptr;
buggy_init(&ptr, sizeof(ptr));
expose_bug(&ptr, sizeof(ptr));
return 0;
}
|