blob: 5f6a7487fd8fb140d409f063ba224a326d2c630e (
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
43
44
45
46
47
48
49
50
|
/* Verify that structure return doesn't invoke memcpy on
overlapping objects. */
extern void abort (void);
extern int inside_main;
typedef __SIZE_TYPE__ size_t;
struct S {
char stuff[1024];
};
union U {
struct {
int space;
struct S s;
} a;
struct {
struct S s;
int space;
} b;
};
struct S f(struct S *p)
{
return *p;
}
void g(union U *p)
{
}
void *memcpy(void *a, const void *b, size_t len)
{
if (inside_main)
{
if (a < b && a+len > b)
abort ();
if (b < a && b+len > a)
abort ();
return a;
}
else
{
char *dst = (char *) a;
const char *src = (const char *) b;
while (len--)
*dst++ = *src++;
return a;
}
}
|