Asan bug or feature?

Hi all,

By hunting after address error in our app I have found unexpected asan
behaviour

Here is a minimal isolated example which runs without address error:

clang++ a.cpp -fsanitize=address

cat a.cpp

char* subroutine()
{
  char* p = new char[8]();
  return p;
}

int main( int /*argc*/, char** /*argv*/ )
{
  char* pc_sub = subroutine();
  char* pc_main = new char[8]();
  pc_main[32] = 1; //points to pc_sub, no ERROR :frowning:
// pc_main[16] = 2; //points to bad address ERROR :slight_smile:
  pc_sub[-32] = 3; //points to pc_main, no ERROR :frowning:
  delete pc_main;
  delete pc_sub;
  return 0;
}

Regards

Miroslav