Debug by breakpoint setting on "std::logic_error"

How to debug by breakpoint set the
'std::logic_error
what(): basic_string::_M_construct null not valid'


how to apply assert() on such ?
Last edited on
Look at the call stack. Identify the function in that call stack that is your code. That's where the error is.
how to apply assert() on such ?

it's not good practice to mix asserts and exceptions.
the point of exception handling is to resolve the error if possible and continue running program. abort if problem can't be resolved.

assert is used only for debug builds. so mixing with exceptions which are applicable for both release and debug build is bad design.

if you just want to show the message of an exception, do it in catch block.
otherwise use a breakpoint in catch block if you want to break on error, and then as Repeater suggested you look at call stack in your IDE, to see from which function error originated.
Last edited on
It's not good practice to mix asserts and exceptions.

Disagree. The features have different purposes.

In the course of a program's execution, whether exceptions are thrown or not, correctness should always be maintained. try-catch is just a control structure. Exceptions may be thrown in the course of normal execution.

Assertions indicate that fundamental program correctness has been lost. Assertions should never fail in the course of normal execution.
Last edited on
Topic archived. No new replies allowed.