1 // RUN: %clangxx_asan -g -O2 %s -o %t
2 // RUN: not %run %t g 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=GLOB
3 // RUN: not %run %t c 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=CLASS_STATIC
4 // RUN: not %run %t f 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=FUNC_STATIC
5 // RUN: not %run %t l 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=LITERAL
7 // COFF doesn't support debuginfo for globals. For the non-debuginfo tests, see global-location-nodebug.cpp.
8 // XFAIL: target={{.*windows-msvc.*}}
10 // FIXME: Investigate failure on MinGW
11 // XFAIL: target={{.*-windows-gnu}}
13 // atos doesn't show source line numbers for global variables.
14 // UNSUPPORTED: darwin
16 // CHECK: AddressSanitizer: global-buffer-overflow
22 // CLASS_STATIC: 0x{{.*}} is located 4 bytes after global variable 'C::array' defined in '{{.*}}global-location.cpp:[[@LINE-1]]' {{.*}} of size 40
26 // GLOB: 0x{{.*}} is located 4 bytes after global variable 'global' defined in '{{.*}}global-location.cpp:[[@LINE-1]]' {{.*}} of size 40
29 int main(int argc
, char **argv
) {
32 case 'g': return global
[one
* 11];
33 case 'c': return C::array
[one
* 11];
36 // FUNC_STATIC: 0x{{.*}} is located 4 bytes after global variable 'main::array' defined in '{{.*}}global-location.cpp:[[@LINE-1]]' {{.*}} of size 40
38 return array
[one
* 11];
40 const char *str
= "0123456789";
41 // LITERAL: 0x{{.*}} is located 0 bytes after global variable {{.*}} defined in '{{.*}}global-location.cpp:[[@LINE-1]]' {{.*}} of size 11
47 // CHECK: SUMMARY: AddressSanitizer: global-buffer-overflow