If you don’t know already, learn how to use a debugger. Also valgrind is very helpful. And if it hasn’t changed in the last years, Clang usually provides more user friendly error messages compared to GCC.
AddressSanitizer aka libasan is also wonderful for tracking memory errors. I find it both faster than valgrind and it has fewer false positives. I still use valgrind for 3rd party code, but prefer libasan for first party code, and insist on a clean run of the unit test suite using a libasan build before merging.