[all-commits] [llvm/llvm-project] d58c7a: [IR] Added operator delete to subclasses of User t...

Moritz Sichert via All-commits all-commits at lists.llvm.org
Thu Jul 8 03:00:02 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d58c7a92380e030af6e6f82ce55bc14a919f39ea
      https://github.com/llvm/llvm-project/commit/d58c7a92380e030af6e6f82ce55bc14a919f39ea
  Author: Moritz Sichert <sichert at in.tum.de>
  Date:   2021-07-08 (Thu, 08 Jul 2021)

  Changed paths:
    M llvm/include/llvm/Analysis/MemorySSA.h
    M llvm/include/llvm/IR/Constants.h
    M llvm/include/llvm/IR/GlobalIndirectSymbol.h
    M llvm/include/llvm/IR/InstrTypes.h
    M llvm/include/llvm/IR/Instructions.h
    M llvm/lib/IR/ConstantsContext.h

  Log Message:
  -----------
  [IR] Added operator delete to subclasses of User to avoid UB

Several subclasses of User override operator new without also overriding
operator delete. This means that delete expressions fall back to using
operator delete of the base class, which would be User. However, this is
only allowed if the base class has a virtual destructor which is not the
case for User, so this is UB.

See also [expr.delete] (3) for the exact wording.

This is actually detected in some cases by GCC 11's
-Wmismatched-new-delete now which is how I found this error.

Differential Revision: https://reviews.llvm.org/D103143




More information about the All-commits mailing list