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

Unified Diff: base/tools_sanity_unittest.cc

Issue 8429008: Prevent clang from optimizing away a variable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 2 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/tools_sanity_unittest.cc
diff --git a/base/tools_sanity_unittest.cc b/base/tools_sanity_unittest.cc
index 249ec71946a568bc3f20f289c4135008d1b7ca11..ec7b1cc93949f889d1d92348782fb5d1c788ff4a 100644
--- a/base/tools_sanity_unittest.cc
+++ b/base/tools_sanity_unittest.cc
@@ -74,7 +74,8 @@ void MakeSomeErrors(char *ptr, size_t size) {
// A memory leak detector should report an error in this test.
TEST(ToolsSanityTest, MemoryLeak) {
- int *leak = new int[256]; // Leak some memory intentionally.
+ // Without the |volatile|, clang optimizes away the next two lines.
+ int* volatile leak = new int[256]; // Leak some memory intentionally.
leak[4] = 1; // Make sure the allocated memory is used.
}
« 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