brintos

brintos / llvm-project-archived public Read only

0
0
Text · 950 B · ff753ca Raw
34 lines · cpp
1// RUN: %clangxx_asan -O0 -fsanitize-address-field-padding=1  %s -o %t2// RUN: not %run %t 11 2>&1 | FileCheck %s3// RUN: %run %t 104//5// FIXME: fix 32-bits.6// REQUIRES: asan-64-bits, shadow-scale-37// FIXME: Implement ASan intra-object padding in Clang's MS record layout8// UNSUPPORTED: target={{.*windows-msvc.*}}9#include <stdio.h>10#include <stdlib.h>11class Foo {12 public:13  Foo() : pre1(1), pre2(2), post1(3), post2(4) {14  }15  virtual ~Foo() {16  }17  void set(int i, int val) { a[i] = val; }18// CHECK: ERROR: AddressSanitizer: intra-object-overflow19// CHECK: #0 {{.*}}Foo::set{{.*}}intra-object-overflow.cpp:[[@LINE-2]]20 private:21  int pre1, pre2;22  int a[11];23  int post1, post2;24};25 26int main(int argc, char **argv) {27  int idx = argc == 2 ? atoi(argv[1]) : 0;28  Foo *foo = new Foo;29  foo->set(idx, 42);30// CHECK: #1 {{.*}}main{{.*}}intra-object-overflow.cpp:[[@LINE-1]]31// CHECK: is located 84 bytes inside of 128-byte region32  delete foo;33}34