Login to manage your account

Please enter a valid email address.
Forgot Password?
Please enter a valid password.
OR

Don't have an account yet? Sign up

Describe a difficult bug you tracked down in C++. How did you find it?

C++ bugs are distinctive because the symptom is often far from the cause, so the method matters more than the fix.

  • The symptom. The classic C++ story is a crash somewhere unrelated to the broken code, or behaviour that changes between debug and release builds, or a failure that disappears when you add a print statement. Any of these points at undefined behaviour.
  • The tools. Say which ones and what each found: AddressSanitizer for out-of-bounds access and use-after-free, UndefinedBehaviorSanitizer for signed overflow and bad casts, ThreadSanitizer for data races, Valgrind for leaks, and a debugger with a watchpoint on the corrupted address.
  • The root cause. Good ones: a dangling reference to a destroyed temporary, iterator invalidation after a vector reallocated, a missing virtual destructor, a race on a shared variable, or reading past the end of a buffer.
  • The systemic fix — turning on sanitizers in CI, or replacing a raw pointer with a smart pointer so the class of bug becomes impossible.

Note: Explaining that undefined behaviour lets the compiler assume the bad case cannot happen — and therefore optimise on that assumption — shows genuine depth.

All C++ interview questions

Login to manage your account

Please enter a valid email address.
Forgot Password?
Please enter a valid password.
OR

Don't have an account yet? Sign up as