[PATCH] D51317: Keep BumpPtrAllocator::Allocate(0) from returning nullptr

Brent Royal-Gordon via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 30 16:56:12 PDT 2018


brentdax added a comment.

I locally tried adding an assert(Size > 0), but also making Allocate<T>()--which doesn't have any of these attributes--return nullptr for zero elements. This design broke 1,060 tests, mostly in clang but a few in LLVM too. So asserting is going to break a ton of code. (I also tried making it waste some space, but only if you don't go through Allocate<T>()—this worked fine.)

So I think our options are:

1. Assert and cause widespread breakage.
2. Remove at least one of the two attributes.
3. Waste a little memory per allocation (if it's not done through Allocate<T>()).
4. Allocate from a guard page, or otherwise return unique invalid pointers.


Repository:
  rL LLVM

https://reviews.llvm.org/D51317





More information about the llvm-commits mailing list