[PATCH] D33305: [ubsan] Add a check for pointer overflow UB

John Regehr via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 7 09:29:40 PDT 2017


regehr added a comment.

Well, my second program should subtract a multiple of sizeof(T). But anyway, my view is that this is a real overflow and a nasty consequence of the unsigned size_t and the usual arithmetic conversions and I don't think we want to try to poke a hole in UBSan to allow this idiom unless it turns out to be extremely common.

I think it would be better style to cast the sizeof() to a ptrdiff_t rather than to an int, but as long as d is a ptrdiff_t this won't matter.


Repository:
  rL LLVM

https://reviews.llvm.org/D33305





More information about the cfe-commits mailing list