* 30_threads/condition_variable_any/cond.cc: New test.
authorMarek Polacek <polacek@redhat.com>
Thu, 26 Jul 2018 21:23:12 +0000 (21:23 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Thu, 26 Jul 2018 21:23:12 +0000 (21:23 +0000)
From-SVN: r263022

libstdc++-v3/ChangeLog
libstdc++-v3/testsuite/30_threads/condition_variable_any/cond.cc [new file with mode: 0644]

index 204b89b..00fb914 100644 (file)
@@ -1,5 +1,9 @@
 2018-07-26  Marek Polacek  <polacek@redhat.com>
 
+       * testsuite/30_threads/condition_variable_any/cond.cc: New.
+
+2018-07-26  Marek Polacek  <polacek@redhat.com>
+
        * src/c++98/locale_init.cc: Fix #ifdef condition.
 
 2018-07-26  Jonathan Wakely  <jwakely@redhat.com>
diff --git a/libstdc++-v3/testsuite/30_threads/condition_variable_any/cond.cc b/libstdc++-v3/testsuite/30_threads/condition_variable_any/cond.cc
new file mode 100644 (file)
index 0000000..82a9e66
--- /dev/null
@@ -0,0 +1,35 @@
+// { dg-do run }
+// { dg-options "-pthread"  }
+// { dg-require-effective-target c++11 }
+// { dg-require-effective-target pthread }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2018 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <condition_variable>
+#include <cstring>
+
+int main()
+{
+  const size_t sz = sizeof(std::condition_variable_any);
+  char garbage[sz];
+  memset(garbage, 0xff, sz);
+  auto cond = new ((void*)garbage) std::condition_variable_any();
+  cond->notify_all();
+  cond->~condition_variable_any();
+}