1 /* Verify -Wstringop-overread with a source pointer pointing either
2 before the beginning or past the end of an object.
4 { dg-options "-O -Wall -Wno-array-bounds" } */
6 typedef __SIZE_TYPE__
size_t;
8 size_t strlen (const char *);
10 void sink (void*, ...);
12 void off_sz_or_1 (size_t i
)
16 /* Verify the offset in the notes only mentions the meaningful lower
17 bound and not a range with the excessive (and meaningless) upper
18 bound like [2, 9223372036854775807]. */
20 // { dg-message "at offset 1 into source object 'a'" "note" { target *-*-* } .-1 }
21 // { dg-message "at offset 2 " "note" { target *-*-* } .-2 }
28 n
+= strlen (p1
); // { dg-warning "reading 1 or more bytes from a region of size 0" }
29 n
+= strlen (p2
); // { dg-warning "reading 1 or more bytes from a region of size 0" }
36 void off_sz_or_2 (size_t i
)
41 // { dg-message "at offset 2 " "note" { target *-*-* } .-1 }
42 // { dg-message "at offset 3 " "note" { target *-*-* } .-2 }
49 n
+= strlen (p1
); // { dg-warning "reading 1 or more bytes from a region of size 0" }
50 n
+= strlen (p2
); // { dg-warning "reading 1 or more bytes from a region of size 0" }
57 void off_sz_or_4 (size_t i
)
62 // { dg-message "at offset 4 " "note" { target *-*-* } .-1 }
63 // { dg-message "at offset 5 " "note" { target *-*-* } .-2 }
64 // { dg-message "at offset 3 " "note" { target *-*-* } .-3 }
71 n
+= strlen (p1
); // { dg-warning "reading 1 or more bytes from a region of size 0" }
72 n
+= strlen (p2
); // { dg-warning "reading 1 or more bytes from a region of size 0" }
73 n
+= strlen (p3
); // { dg-warning "reading 1 or more bytes from a region of size 0" }