diff --git a/src/cpu/o3/dyn_inst.cc b/src/cpu/o3/dyn_inst.cc index 0b9a900446..94433cf433 100644 --- a/src/cpu/o3/dyn_inst.cc +++ b/src/cpu/o3/dyn_inst.cc @@ -187,6 +187,15 @@ DynInst::operator new(size_t count, Arrays &arrays) return buf; } +// Because of the custom "new" operator that allocates more bytes than the +// size of the DynInst object, AddressSanitizer throw new-delete-type-mismatch. +// Adding a custom delete function is enough to shut down this false positive +void +DynInst::operator delete(void *ptr) +{ + ::operator delete(ptr); +} + DynInst::~DynInst() { /* diff --git a/src/cpu/o3/dyn_inst.hh b/src/cpu/o3/dyn_inst.hh index ab165bbcd5..54c0385374 100644 --- a/src/cpu/o3/dyn_inst.hh +++ b/src/cpu/o3/dyn_inst.hh @@ -95,6 +95,7 @@ class DynInst : public ExecContext, public RefCounted }; static void *operator new(size_t count, Arrays &arrays); + static void operator delete(void* ptr); /** BaseDynInst constructor given a binary instruction. */ DynInst(const Arrays &arrays, const StaticInstPtr &staticInst,