|
From: <sv...@va...> - 2013-10-02 16:22:34
|
Author: bart
Date: Wed Oct 2 16:22:23 2013
New Revision: 13606
Log:
drd/tests/annotate_smart_pointer: Avoid non-POD variable length arrays
Non-POD variable length arrays are supported by g++ but not by clang.
Hence convert the variable length array in this test program into a vector.
Modified:
trunk/drd/tests/annotate_smart_pointer.cpp
Modified: trunk/drd/tests/annotate_smart_pointer.cpp
==============================================================================
--- trunk/drd/tests/annotate_smart_pointer.cpp (original)
+++ trunk/drd/tests/annotate_smart_pointer.cpp Wed Oct 2 16:22:23 2013
@@ -29,6 +29,7 @@
#include <climits> // PTHREAD_STACK_MIN
#include <iostream> // std::cerr
#include <stdlib.h> // atoi()
+#include <vector>
#ifdef _WIN32
#include <process.h> // _beginthreadex()
#include <windows.h> // CRITICAL_SECTION
@@ -311,12 +312,11 @@
for (int j = 0; j < iterations; ++j)
{
- Thread T[nthreads];
-
+ std::vector<Thread> T(nthreads);
smart_ptr<counter> p(new counter);
p->post_increment();
- for (int i = 0; i < nthreads; ++i)
- T[i].Create(thread_func, new smart_ptr<counter>(p));
+ for (std::vector<Thread>::iterator q = T.begin(); q != T.end(); q++)
+ q->Create(thread_func, new smart_ptr<counter>(p));
{
// Avoid that counter.m_mutex introduces a false ordering on the
// counter.m_count accesses.
@@ -324,8 +324,8 @@
nanosleep(&delay, 0);
}
p = NULL;
- for (int i = 0; i < nthreads; ++i)
- T[i].Join();
+ for (std::vector<Thread>::iterator q = T.begin(); q != T.end(); q++)
+ q->Join();
}
std::cerr << "Done.\n";
return 0;
|