brintos

brintos / llvm-project-archived public Read only

0
0
Text · 849 B · 0b0f15c Raw
43 lines · cpp
1// A global constructor from a non-instrumented part calls a function2// in an instrumented part.3// Regression test for https://code.google.com/p/address-sanitizer/issues/detail?id=363.4 5// RUN: %clangxx      -DINSTRUMENTED_PART=0 -c %s -o %t-uninst.o6// RUN: %clangxx_asan -DINSTRUMENTED_PART=1 -c %s -o %t-inst.o7// RUN: %clangxx_asan %t-uninst.o %t-inst.o -o %t8 9// RUN: %run %t 2>&1 | FileCheck %s10 11#include <stdio.h>12#include <stdlib.h>13#include <string.h>14 15void func(char *ptr);16 17#if INSTRUMENTED_PART == 118 19void func(char *ptr) {20  *ptr = 'X';21}22 23#else // INSTRUMENTED_PART == 124 25struct C1 {26  C1() {27    printf("Hello ");28    char buffer[10] = "world";29    func(buffer);30    printf("%s\n", buffer);31  }32};33 34C1 *obj = new C1();35 36int main(int argc, const char *argv[]) {37  return 0;38}39 40#endif // INSTRUMENTED_PART == 141 42// CHECK: Hello Xorld43