[PATCH] D29610: Fix BucketT Handling in DenseMap.

Alexis Shaw via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 6 17:27:07 PST 2017


varno added inline comments.


================
Comment at: include/llvm/ADT/DenseMap.h:111
+          P->~BucketT();
+          ::new (&P->getFirst()) KeyT(EmptyKey);
           --NumEntries;
----------------
dberris wrote:
> This smells funny -- first you destroy the object, then call a function on the destroyed object. I'm positive you are running into undefined behaviour here. To fix this, you should attempt to re-initialize the object pointed to through P using placement new.
This is no more smelly than the initial problems. if you look at the source code, the BucketTs are not initialized anywhere. There is never a constructor called on them. This is no different to how they are initialized initially. See line 326, in the file.

I am just making it less bad. Really we need to initialize the buckets correctly, however this requires more work than I can spare.


https://reviews.llvm.org/D29610





More information about the llvm-commits mailing list