forked from OSchip/llvm-project
[ASan/Win] Hide index from compiler to avoid new clang warning
This commit is contained in:
parent
37a2c4517b
commit
b9af157fd1
|
@ -7,10 +7,12 @@ struct C {
|
|||
~C() {}
|
||||
};
|
||||
|
||||
int __attribute__((noinline, optnone)) hide(int x) { return x; }
|
||||
|
||||
extern "C" __declspec(dllexport)
|
||||
int test_function() {
|
||||
C *buffer = new C[42];
|
||||
buffer[-(1 + sizeof(void*) / 4)].x = 42;
|
||||
buffer[hide(-(1 + (int)sizeof(void*) / 4))].x = 42;
|
||||
// CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
|
||||
// CHECK: WRITE of size 4 at [[ADDR]] thread T0
|
||||
// CHECK-NEXT: test_function {{.*}}dll_operator_array_new_with_dtor_left_oob.cpp:[[@LINE-3]]
|
||||
|
|
|
@ -6,9 +6,11 @@ struct C {
|
|||
~C() {}
|
||||
};
|
||||
|
||||
int __attribute__((noinline, optnone)) hide(int x) { return x; }
|
||||
|
||||
int main() {
|
||||
C *buffer = new C[42];
|
||||
buffer[-(1 + sizeof(void*) / 4)].x = 42;
|
||||
buffer[hide(-(1 + (int)sizeof(void*) / 4))].x = 42;
|
||||
// CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
|
||||
// CHECK: WRITE of size 4 at [[ADDR]] thread T0
|
||||
// CHECK-NEXT: {{#0 .* main .*operator_array_new_with_dtor_left_oob.cpp}}:[[@LINE-3]]
|
||||
|
|
Loading…
Reference in New Issue