summaryrefslogtreecommitdiffstats
path: root/source/slangc/main.cpp
diff options
context:
space:
mode:
authorJay Kwak <82421531+jkwak-work@users.noreply.github.com>2024-07-25 22:17:01 -0700
committerGitHub <noreply@github.com>2024-07-25 22:17:01 -0700
commita4eac09102336e082823217ebb01402880ab2823 (patch)
treee04787c2753fbc565c9f7b9e95e18373e305509d /source/slangc/main.cpp
parent0fe55d6d8793fcd005b6d3c0ccaa0afbc27c069f (diff)
Assertion failure on debug build for memory leaks (#4733)
This commit makes the memory leaks harder to miss by triggering an assertion failure for memory leaks. It works only for Windows Debug build. SLANG_ASSERT doesn't print the info where the assertion failure happens, for an unknown reason. Using the system assert as a workaround.
Diffstat (limited to 'source/slangc/main.cpp')
-rw-r--r--source/slangc/main.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/source/slangc/main.cpp b/source/slangc/main.cpp
index 2907625ed..6e76e2f93 100644
--- a/source/slangc/main.cpp
+++ b/source/slangc/main.cpp
@@ -140,6 +140,7 @@ int wmain(int argc, wchar_t** argv)
}
#ifdef _MSC_VER
+ // _CrtXXX functions are functional only for debug build. The spec says,
// "When _DEBUG isn't defined, calls to _CrtSetReportMode are removed
// during preprocessing."
_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
@@ -149,7 +150,9 @@ int wmain(int argc, wchar_t** argv)
_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
_CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
- _CrtDumpMemoryLeaks();
+ int memleakDetected = _CrtDumpMemoryLeaks();
+ SLANG_UNUSED(memleakDetected);
+ assert(!memleakDetected);
#endif
return result;