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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
/* PR tree-optimization/83640 - ice in generic_overlap, at
gimple-ssa-warn-restrict.c:814
Test to verify that a pointer offset range whose upper bound is less
than its lower bound (when interpreted as a signed integer) is handled
correctly.
{ dg-do compile }
{ dg-options "-O2 -Wrestrict" } */
#include "range.h"
extern char* strcpy (char*, const char*);
extern char* stpcpy (char*, const char*);
void sink (void*);
void warn_2_smax_p2 (void)
{
char a[7] = "01234";
char *d = a;
ptrdiff_t i = UR (2, DIFF_MAX + (size_t)2);
strcpy (d, d + i); /* { dg-warning "accessing between 1 and 4 bytes at offsets 0 and \\\[2, 7] may overlap up to 2 bytes at offset \\\[2, 3]" } */
sink (d);
}
void nowarn_3_smax_p2 (void)
{
char a[7] = "12345";
char *d = a;
ptrdiff_t i = UR (3, DIFF_MAX + (size_t)2);
strcpy (d, d + i);
sink (d);
}
void warn_2u_smax_p2 (void)
{
char a[7] = "23456";
char *d = a;
size_t i = UR (2, DIFF_MAX + (size_t)2);
strcpy (d, d + i); /* { dg-warning "accessing between 1 and 4 bytes at offsets 0 and \\\[2, 7] may overlap up to 2 bytes at offset \\\[2, 3]" } */
sink (d);
}
void nowarn_3u_smax_p2 (void)
{
char a[7] = "34567";
char *d = a;
size_t i = UR (3, DIFF_MAX + (size_t)2);
strcpy (d, d + i);
sink (d);
}
|