[PATCH] D103143: [IR] Added operator delete to subclasses of User to avoid UB

Moritz Sichert via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 26 02:15:50 PDT 2021


MoritzS created this revision.
Herald added subscribers: dexonsmith, asbirlea, george.burgess.iv, hiraditya.
MoritzS requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103143

Files:
  llvm/include/llvm/Analysis/MemorySSA.h
  llvm/include/llvm/IR/Constants.h
  llvm/include/llvm/IR/GlobalIndirectSymbol.h
  llvm/include/llvm/IR/InstrTypes.h
  llvm/include/llvm/IR/Instructions.h
  llvm/lib/IR/ConstantsContext.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103143.347867.patch
Type: text/x-patch
Size: 13350 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210526/a916f9ff/attachment.bin>


More information about the llvm-commits mailing list