blob: 8248dad213b466cc663532a998a3649e05550fda (
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
51
52
53
54
55
56
57
58
|
/* Verify -Wstringop-overread with a source pointer pointing either
before the beginning or past the end of an object.
{ dg-do compile }
{ dg-options "-O -Wall" } */
typedef __SIZE_TYPE__ size_t;
size_t strlen (const char *);
extern char a[1];
volatile size_t n;
void len_si_1_max (int i)
{
if (i < 1) i = 1;
n = strlen (a + i); // { dg-warning "reading 1 or more bytes from a region of size 0" }
n = strlen (a + i + 1); // { dg-warning "reading 1 or more bytes from a region of size 0" }
}
void len_ui_1_max (unsigned i)
{
if (i < 1) i = 1;
n = strlen (a + i); // { dg-warning "reading 1 or more bytes from a region of size 0" }
n = strlen (a + i + 1); // { dg-warning "reading 1 or more bytes from a region of size 0" "" { xfail ilp32 } }
}
void len_sl_1_max (long i)
{
if (i < 1) i = 1;
n = strlen (a + i); // { dg-warning "reading 1 or more bytes from a region of size 0" }
n = strlen (a + i + 1); // { dg-warning "reading 1 or more bytes from a region of size 0" }
}
void len_ul_1_max (unsigned long i)
{
if (i < 1) i = 1;
n = strlen (a + i); // { dg-warning "reading 1 or more bytes from a region of size 0" }
n = strlen (a + i + 1); // { dg-warning "reading 1 or more bytes from a region of size 0" "" { xfail *-*-* } }
}
void len_si_min_m1 (int i)
{
if (i > -1) i = -1;
n = strlen (a + i - 1); // { dg-warning "reading 1 or more bytes from a region of size 0" "" { xfail lp64 } }
n = strlen (a + i); // { dg-warning "reading 1 or more bytes from a region of size 0" "" { xfail *-*-* } }
n = strlen (a + i + 2);
}
void len_sl_min_m1 (long i)
{
if (i > -1) i = -1;
n = strlen (a + i - 1); // { dg-warning "reading 1 or more bytes from a region of size 0" }
n = strlen (a + i); // { dg-warning "reading 1 or more bytes from a region of size 0" "" { xfail *-*-* } }
n = strlen (a + i + 2);
}
|