Imported Upstream version 4.8.1
[platform/upstream/gcc48.git] / gcc / testsuite / c-c++-common / asan / null-deref-1.c
1 /* { dg-do run } */
2 /* { dg-options "-fno-omit-frame-pointer -fno-shrink-wrap" } */
3 /* { dg-additional-options "-mno-omit-leaf-frame-pointer" { target { i?86-*-* x86_64-*-* } } } */
4 /* { dg-shouldfail "asan" } */
5
6 __attribute__((noinline, noclone))
7 static void
8 NullDeref(int *ptr)
9 {
10   ptr[10]++;
11 }
12
13 int main()
14 {
15   NullDeref((int*)0);
16   return 0;
17 }
18
19 /* { dg-output "ERROR: AddressSanitizer:? SEGV on unknown address\[^\n\r]*" } */
20 /* { dg-output "0x\[0-9a-f\]+ \[^\n\r]*pc 0x\[0-9a-f\]+\[^\n\r]*(\n|\r\n|\r)" } */
21 /* { dg-output "AddressSanitizer can not provide additional info.*(\n|\r\n|\r)" } */
22 /* { dg-output "    #0 0x\[0-9a-f\]+ (in \[^\n\r]*NullDeref\[^\n\r]* (\[^\n\r]*null-deref-1.c:10|\[^\n\r]*:0)|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
23 /* { dg-output "    #1 0x\[0-9a-f\]+ (in _*main (\[^\n\r]*null-deref-1.c:15|\[^\n\r]*:0)|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */