[PATCH] D116861: [UBSan] Fix incorrect alignment reported when global new returns an offset pointer

John McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 8 18:05:28 PST 2022


rjmccall added inline comments.


================
Comment at: clang/lib/CodeGen/CGExprCXX.cpp:1658-1659
           Target.getNewAlign(), getContext().getTypeSize(allocType)));
       allocationAlign = std::max(
           allocationAlign, getContext().toCharUnitsFromBits(AllocatorAlign));
     }
----------------
rnk wrote:
> I believe John's proposal is to remove this `max` here.
Or to at least use something more conservative, like the alignment of a pointer.  Or even potentially to fix `getNewAlign()` so that we're only aggressive about it on targets (like Darwin) that have more explicitly authorized us to be so.  But in any case, we should make the change up here instead of only in the UBSan check.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D116861/new/

https://reviews.llvm.org/D116861



More information about the cfe-commits mailing list