Chromium Code Reviews

Unified Diff: test/cctest/test-mark-compact.cc

Issue 12218051: Fix NULL-pointer arithmetic abuse in tests surfaced by clang (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
« 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: test/cctest/test-mark-compact.cc
diff --git a/test/cctest/test-mark-compact.cc b/test/cctest/test-mark-compact.cc
index 48610b09acf78e8781ee07580f4c02531e50eb94..45d093290af3096dcac5c8aa4751673086e22cea 100644
--- a/test/cctest/test-mark-compact.cc
+++ b/test/cctest/test-mark-compact.cc
@@ -53,6 +53,7 @@ static void InitializeVM() {
TEST(MarkingDeque) {
+ InitializeVM();
int mem_size = 20 * kPointerSize;
byte* mem = NewArray<byte>(20*kPointerSize);
Address low = reinterpret_cast<Address>(mem);
@@ -60,19 +61,20 @@ TEST(MarkingDeque) {
MarkingDeque s;
s.Initialize(low, high);
- Address address = NULL;
+ Address original_address = reinterpret_cast<Address>(&s);
+ Address current_address = original_address;
while (!s.IsFull()) {
- s.PushBlack(HeapObject::FromAddress(address));
- address += kPointerSize;
+ s.PushBlack(HeapObject::FromAddress(current_address));
+ current_address += kPointerSize;
}
while (!s.IsEmpty()) {
Address value = s.Pop()->address();
- address -= kPointerSize;
- CHECK_EQ(address, value);
+ current_address -= kPointerSize;
+ CHECK_EQ(current_address, value);
}
- CHECK_EQ(NULL, address);
+ CHECK_EQ(current_address, original_address);
Sven Panne 2013/02/07 09:02:10 swap arguments to match expected/actual
DeleteArray(mem);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine