view compiler-rt/test/hwasan/TestCases/new-test.cpp @ 221:79ff65ed7e25

LLVM12 Original
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 15 Jun 2021 19:15:29 +0900
parents 1d019706d866
children c4bab56944e8
line wrap: on
line source

// Test basic new functionality.
// RUN: %clangxx_hwasan %s -o %t
// RUN: %run %t

#include <stdlib.h>
#include <assert.h>
#include <sanitizer/hwasan_interface.h>
#include <sanitizer/allocator_interface.h>

int main() {
  __hwasan_enable_allocator_tagging();

  size_t volatile n = 0;
  char *a1 = new char[n];
  assert(a1 != nullptr);
  assert(__sanitizer_get_allocated_size(a1) == 0);
  delete[] a1;
}