Re:Don’t blindly prefer emplace_back to push_back
by vbezhenar on Thursday March 04, 2021 @05:55AM
(#26340935)
If you're using Linux, run your test programs under valgrind. It'll help you immensely to find memory issues.
Re:Don’t blindly prefer emplace_back to push_back
by readams on Thursday March 04, 2021 @06:58AM
(#26341317)
I mostly use address sanitizer these days rather than valgrind. It's fast enough that you can just put it in your default compile flags for debugging.
Re:Don’t blindly prefer emplace_back to push_back
by junon on Thursday March 04, 2021 @08:25AM
(#26342018)
Address sanitizers have bitten me before. Valgrind has not, aside from the times it wasn't supported on new macos.
Just be careful.
- dangling pointers
- integer under/overflow
- macro expansion (not via debugger but VSCode helps with this)
- double values not being the same when you expect them to be the same
- Seeing if something is copied or moved [1]
[1] Not sure if this is actually true. But I think it can be true by simply stepping inside the function like emplace_back