Try Catch For Bad Memory Access

a_unique_name 401 Reputation points
2022-02-11T18:34:05.973+00:00

Developing on Windows 10 Pro, Visual Studio 2022 Community.

I've noticed that accessing bad memory doesn't get caught with try and catch clauses.

It's treated as an unhandled exception and an box pops up telling me about the issue.

I'm having a problem right now with a bad pointer, probably to a deleted class instance.

I have a diagnostic with an edit window where I'm stuffing a lot of information that should help me find the guilty code.

It would be very nice to catch the exception and continue execution so I can scroll through that edit control.

Any suggestions?

Thanks
Larry

Developer technologies | C++
0 comments No comments
{count} votes

Accepted answer
  1. David Lowndes 4,726 Reputation points
    2022-02-11T19:18:40.817+00:00

    To catch such exceptions I think you'll need to use Structured Exception Handling SEH.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.