The perfect-forwarding constructor in `BumpPtrAllocatorImpl`

Curious: what is the purpose of the perfect-forwarding constructor in llvm::BumpPtrAllocatorImpl here?
I had a really confusing bug where I accidentally missed the & when writing a function that takes in a BumpPtrAllocator as a parameter, so the data copied did not end up where I wanted :upside_down_face: . Took me a while to find out what happened.

I was super surprised that you can “copy” an allocator, seeing that BumpPtrAllocatorImpl has user-defined move constructor and move assignment operator so the implicit copy constructor would be deleted. And then I found this little forwarding constructor, silently taking over my pass-allocator-by-value function.

What I think happened was the forwarding constructor expanded to BumpPtrAllocatorImpl(BumpPtrAllocator &) , then forwarded it to the base MallocAllocator which doesn’t have any field or user-defined c’tor. So it basically default-constructed a blank BumpPtrAllocator in my copy function.

I generally believe that perfect-forwarding could be dangerous in some cases because it sometimes match things too perfectly. So why in this case? Could it be improved?

I just posted a patch:
Please feel free to make comments and let me know if this is the correct way to go!