issue-425: Fixed tcmalloc unittest crashes for windows builds

Missing use of volatile was causing vs2010 to perform unwanted
optimization resulting in the crash. See issue for more details.


git-svn-id: http://gperftools.googlecode.com/svn/trunk@198 6b5cf1ce-ec42-a296-1ba9-69fdba395a50
This commit is contained in:
chappedm@gmail.com 2013-03-11 01:35:37 +00:00
parent beb78cc05b
commit 5037f687d1

View File

@ -725,7 +725,7 @@ static void TestNothrowNew(void* (*func)(size_t, const std::nothrow_t&)) {
// Note the ... in the hook signature: we don't care what arguments
// the hook takes.
#define MAKE_HOOK_CALLBACK(hook_type) \
static int g_##hook_type##_calls = 0; \
static volatile int g_##hook_type##_calls = 0; \
static void IncrementCallsTo##hook_type(...) { \
g_##hook_type##_calls++; \
} \
@ -760,7 +760,7 @@ static void TestAlignmentForSize(int size) {
CHECK((p % sizeof(void*)) == 0);
CHECK((p % sizeof(double)) == 0);
// Must have 16-byte (or 8-byte in case of -DTCMALLOC_ALIGN_8BYTES)
// Must have 16-byte (or 8-byte in case of -DTCMALLOC_ALIGN_8BYTES)
// alignment for large enough objects
if (size >= kMinAlign) {
CHECK((p % kMinAlign) == 0);