English
Summary
Conclusions
The search for a defect starts with a reproducible example. The debugger shows the state, but explaining the cause requires an understanding of types, bounds and invariants. RAII supports releasing resources when exceptions occur. Expected makes an error an explicit part of the result. Every interface must define the state after a failure.
Self-check questions
- How does a logic error differ from UB?
- What do you need for a reproducible example?
- How do F10, F11 and Shift+F11 differ?
- When is a conditional breakpoint useful?
- Why can a Watch expression change the state?
- Why doesn’t assert check input in all builds?
- What is destroyed during stack unwinding?
- Why catch by const reference?
- How does throw; differ from throw error;?
- What happens when noexcept is violated?
- What does strong exception safety guarantee?
- When is optional not enough?
- What is the precondition for calling error()?
- How does and_then differ from transform?
- Why doesn’t C++26 in the course title guarantee the debugging API?
Review questions for the lab
- What is the first point of discrepancy?
- When do you need Step Into?
- How does a break on thrown differ from a break on unhandled?
- Why define a custom exception type?
- Why are exceptions caught by const&?
- How does RAII work during an exception?
- What does noexcept mean?
- What does the strong guarantee preserve?
- When is expected appropriate?
- Why doesn’t assert replace input validation?
Useful links
- Exceptions: https://learn.microsoft.com/cpp/cpp/errors-and-exception-handling-modern-cpp.
- Debugging: https://learn.microsoft.com/visualstudio/debugger/getting-started-with-the-debugger-cpp.
- The MSVC implementation of expected: https://github.com/microsoft/STL/blob/main/stl/inc/expected.
- Hot Reload: https://learn.microsoft.com/visualstudio/debugger/hot-reload.