clang/win: Prevent clang from optimizing away a malloc in a test.
Similar to e.g. https://codereview.chromium.org/8429008 and https://codereview.chromium.org/8429008 . BUG=448935 R=scottmg@chromium.org, wfh@chromium.org Review URL: https://codereview.chromium.org/868743003 Cr-Commit-Position: refs/heads/master@{#312673}
This commit is contained in:
@@ -42,7 +42,8 @@ int OnNoMemory(size_t) {
|
||||
|
||||
void ExhaustMemoryWithMalloc() {
|
||||
for (;;) {
|
||||
void* buf = malloc(kLargePermittedAllocation);
|
||||
// Without the |volatile|, clang optimizes away the allocation.
|
||||
void* volatile buf = malloc(kLargePermittedAllocation);
|
||||
if (!buf)
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user