[PATCH] D51317: Handle BumpPtrAllocator::Allocate(0) without undefined behavior

Chandler Carruth via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 4 03:04:35 PDT 2018


chandlerc added a comment.

FWIW, just because a lot of code hits the assert for non-zero size does not (to me) mean that isn't the correct approach.

I actually think that the API is better if allocating zero size is disallowed. I think making clients think about how it makes sense in *their* case to handle this degenerate case is better than trying to do something inside the allocator. I think we'll constantly make one set of users of the API or the other unhappy: either we allocate when we shouldn't to avoid returning a nullptr, or we make clients deal with a potentially-null return.


Repository:
  rL LLVM

https://reviews.llvm.org/D51317





More information about the llvm-commits mailing list