1 // FIXME: https://code.google.com/p/address-sanitizer/issues/detail?id=316
4 // Different size: detect a bug if detect_odr_violation>=1
5 // RUN: %clangxx_asan -DBUILD_SO=1 -fPIC -shared %s -o %t-ODR-SO.so
6 // RUN: %clangxx_asan %s %t-ODR-SO.so -Wl,-R. -o %t-ODR-EXE
7 // RUN: ASAN_OPTIONS=detect_odr_violation=1 not %run %t-ODR-EXE 2>&1 | FileCheck %s
8 // RUN: ASAN_OPTIONS=detect_odr_violation=2 not %run %t-ODR-EXE 2>&1 | FileCheck %s
9 // RUN: ASAN_OPTIONS=detect_odr_violation=0 %run %t-ODR-EXE 2>&1 | FileCheck %s --check-prefix=DISABLED
10 // RUN: not %run %t-ODR-EXE 2>&1 | FileCheck %s
12 // Same size: report a bug only if detect_odr_violation>=2.
13 // RUN: %clangxx_asan -DBUILD_SO=1 -fPIC -shared %s -o %t-ODR-SO.so -DSZ=100
14 // RUN: ASAN_OPTIONS=detect_odr_violation=1 %run %t-ODR-EXE 2>&1 | FileCheck %s --check-prefix=DISABLED
15 // RUN: ASAN_OPTIONS=detect_odr_violation=2 not %run %t-ODR-EXE 2>&1 | FileCheck %s
16 // RUN: not %run %t-ODR-EXE 2>&1 | FileCheck %s
18 // GNU driver doesn't handle .so files properly.
26 namespace foo
{ char G
[SZ
]; }
29 namespace foo
{ char G
[100]; }
30 // CHECK: ERROR: AddressSanitizer: odr-violation
31 // CHECK: size=100 'foo::G' {{.*}}odr-violation.cc:[[@LINE-2]]:22
32 // CHECK: size={{4|100}} 'foo::G'
33 int main(int argc
, char **argv
) {
34 printf("PASS: %p\n", &foo::G
);
38 // CHECK: These globals were registered at these points:
41 // CHECK: SUMMARY: AddressSanitizer: odr-violation: global 'foo::G' at {{.*}}odr-violation.cc