brintos

brintos / llvm-project-archived public Read only

0
0
Text · 770 B · 743e2ae Raw
33 lines · cpp
1// RUN: %clangxx_asan -O0 -mllvm -asan-instrument-dynamic-allocas %s -o %t2// RUN: not %run %t 2>&1 | FileCheck %s3//4// MSVC doesn't support VLAs5// UNSUPPORTED: msvc6 7// This is reduced testcase based on Chromium code.8// See http://reviews.llvm.org/D6055?vs=on&id=15616&whitespace=ignore-all#toc.9 10#include "defines.h"11#include <assert.h>12#include <stdint.h>13 14int a = 7;15int b;16int c;17int *p;18 19ATTRIBUTE_NOINLINE void fn3(int *first, int second) {}20 21int main() {22  int d = b && c;23  int e[a];24  assert(!(reinterpret_cast<uintptr_t>(e) & 31L));25  int f;26  if (d)27    fn3(&f, sizeof 0 * (&c - e));28  e[a] = 0;29// CHECK: ERROR: AddressSanitizer: dynamic-stack-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]30// CHECK: WRITE of size 4 at [[ADDR]] thread T031  return 0;32}33