Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1645)

Unified Diff: base/security_unittest.cc

Issue 868743003: Prevent clang from optimizing away a malloc in a test. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: spellz Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/security_unittest.cc
diff --git a/base/security_unittest.cc b/base/security_unittest.cc
index a7e3bc4bd6e72e95097fa198702337a7664fc7ac..f4c60a75db7291df8f4d51b8a495d48e6915a34d 100644
--- a/base/security_unittest.cc
+++ b/base/security_unittest.cc
@@ -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;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698