diff --git a/src/cpu/o3/dyn_inst.cc b/src/cpu/o3/dyn_inst.cc index c5e54f1886..c0ace7cdae 100644 --- a/src/cpu/o3/dyn_inst.cc +++ b/src/cpu/o3/dyn_inst.cc @@ -191,6 +191,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 3dae156eb1..9b46431b2d 100644 --- a/src/cpu/o3/dyn_inst.hh +++ b/src/cpu/o3/dyn_inst.hh @@ -104,6 +104,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,