PR c++/85662
[official-gcc.git] / gcc / testsuite / c-c++-common / asan / strlen-overflow-1.c
blob86a79fd5d06453497438d9541130966b54854a0e
1 /* { dg-do run } */
2 /* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */
3 /* { dg-shouldfail "asan" } */
5 #include <sanitizer/asan_interface.h>
7 char a[2] = "0";
9 #ifdef __cplusplus
10 extern "C"
11 #endif
12 __SIZE_TYPE__
13 strlen (const char *p);
15 int main () {
16 char *p = &a[0];
17 asm ("" : "+r"(p));
18 __asan_poison_memory_region ((char *)&a[1], 1);
19 return __builtin_strlen (a) + 1;
22 /* { dg-output "READ of size 2 at 0x\[0-9a-f\]+ thread T0.*(\n|\r\n|\r)" } */
23 /* { dg-output " #1 0x\[0-9a-f\]+ +(in _*main (\[^\n\r]*strlen-overflow-1.c:19|\[^\n\r]*:0)|\[(\]).*(\n|\r\n|\r)" } */
24 /* { dg-output "\[^\n\r]*0x\[0-9a-f\]+ is located 0 bytes to the right of global variable" } */