some Address Sanitizer Errors are not reported in VS2022 MFC project.

Ailsa 25 Reputation points
2025-05-14T07:25:09.06+00:00

We can detect some Address Sanitizer Errors using cmd mode, but if we add the same code in MFC project, these errors will not be reported.

For example, if we add code “delete;” in example1.cpp file and use cmd mode to compile and debug it, it will report error of “alloc-dealloc-mismatch”. If we add the same code in one MFC project, it will NOT report errors.

I need to detect these errors in MFC project, how to solve this problem?


--------- below Address Sanitizer Errors have the similar issue ------

 alloc-dealloc-mismatch

 Error: alloc-dealloc-mismatch | Microsoft Learn

container-overflow

Error: container-overflow | Microsoft Learn

memcpy-param-overlap

Error: memcpy-param-overlap | Microsoft Learn

new-delete-type-mismatch

Error: new-delete-type-mismatch | Microsoft Learn

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,935 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. RLWA32 48,746 Reputation points
    2025-05-14T23:56:10.92+00:00

    There are known issues when using ASAN with MFC -- Overriding operator new and delete

    0 comments No comments

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.