]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
drd/tests/annotate_smart_pointer: Avoid non-POD variable length arrays
authorBart Van Assche <bvanassche@acm.org>
Wed, 2 Oct 2013 16:22:23 +0000 (16:22 +0000)
committerBart Van Assche <bvanassche@acm.org>
Wed, 2 Oct 2013 16:22:23 +0000 (16:22 +0000)
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.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13606

drd/tests/annotate_smart_pointer.cpp

index bcf3a78403b2203fdb00c53467ff94cc219796b8..43343022275a52123c983d88c20158c2d19ae5aa 100644 (file)
@@ -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 @@ int main(int argc, char** argv)
 
   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 @@ int main(int argc, char** argv)
       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;