From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- .../testsuite/23_containers/vector/debug/52433.cc | 43 +++++++++ .../23_containers/vector/debug/assign1_neg.cc | 33 +++++++ .../23_containers/vector/debug/assign2_neg.cc | 33 +++++++ .../23_containers/vector/debug/assign3_neg.cc | 33 +++++++ .../23_containers/vector/debug/assign4_neg.cc | 32 +++++++ .../23_containers/vector/debug/construct1_neg.cc | 33 +++++++ .../23_containers/vector/debug/construct2_neg.cc | 33 +++++++ .../23_containers/vector/debug/construct3_neg.cc | 33 +++++++ .../23_containers/vector/debug/construct4_neg.cc | 32 +++++++ .../23_containers/vector/debug/insert1_neg.cc | 33 +++++++ .../23_containers/vector/debug/insert2_neg.cc | 33 +++++++ .../23_containers/vector/debug/insert3_neg.cc | 33 +++++++ .../23_containers/vector/debug/insert4_neg.cc | 32 +++++++ .../23_containers/vector/debug/invalidation/1.cc | 59 ++++++++++++ .../23_containers/vector/debug/invalidation/2.cc | 64 +++++++++++++ .../23_containers/vector/debug/invalidation/3.cc | 89 ++++++++++++++++++ .../23_containers/vector/debug/invalidation/4.cc | 66 ++++++++++++++ .../vector/debug/multithreaded_swap.cc | 100 +++++++++++++++++++++ 18 files changed, 814 insertions(+) create mode 100644 libstdc++-v3/testsuite/23_containers/vector/debug/52433.cc create mode 100644 libstdc++-v3/testsuite/23_containers/vector/debug/assign1_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/vector/debug/assign2_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/vector/debug/assign3_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/vector/debug/assign4_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/vector/debug/construct1_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/vector/debug/construct2_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/vector/debug/construct3_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/vector/debug/construct4_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/vector/debug/insert1_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/vector/debug/insert2_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/vector/debug/insert3_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/vector/debug/insert4_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/vector/debug/invalidation/1.cc create mode 100644 libstdc++-v3/testsuite/23_containers/vector/debug/invalidation/2.cc create mode 100644 libstdc++-v3/testsuite/23_containers/vector/debug/invalidation/3.cc create mode 100644 libstdc++-v3/testsuite/23_containers/vector/debug/invalidation/4.cc create mode 100644 libstdc++-v3/testsuite/23_containers/vector/debug/multithreaded_swap.cc (limited to 'libstdc++-v3/testsuite/23_containers/vector/debug') diff --git a/libstdc++-v3/testsuite/23_containers/vector/debug/52433.cc b/libstdc++-v3/testsuite/23_containers/vector/debug/52433.cc new file mode 100644 index 000000000..f1f5917d1 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/debug/52433.cc @@ -0,0 +1,43 @@ +// Copyright (C) 2012 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 +// . +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// PR libstdc++/52433 + +#include + +struct X +{ + std::vector::iterator i; + + X() = default; + X(const X&) = default; + X(X&&) = default; + X& operator=(const X&) = default; + X& operator=(X&&) = default; +}; + +X test01() +{ + X x; + x = X(); + return x; +} + diff --git a/libstdc++-v3/testsuite/23_containers/vector/debug/assign1_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/debug/assign1_neg.cc new file mode 100644 index 000000000..ff9c5a24b --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/debug/assign1_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010 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 +// . +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include +#include + +void test01() +{ + __gnu_test::check_assign1 >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/debug/assign2_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/debug/assign2_neg.cc new file mode 100644 index 000000000..4384a97bd --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/debug/assign2_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010 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 +// . +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include +#include + +void test01() +{ + __gnu_test::check_assign2 >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/debug/assign3_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/debug/assign3_neg.cc new file mode 100644 index 000000000..9cb7ea6f9 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/debug/assign3_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010 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 +// . +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include +#include + +void test01() +{ + __gnu_test::check_assign3 >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/debug/assign4_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/debug/assign4_neg.cc new file mode 100644 index 000000000..8e3d3be9c --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/debug/assign4_neg.cc @@ -0,0 +1,32 @@ +// Copyright (C) 2010 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 +// . +// +// { dg-do run { xfail *-*-* } } + +#include +#include + +void test01() +{ + __gnu_test::check_assign1<__gnu_debug::vector >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/debug/construct1_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/debug/construct1_neg.cc new file mode 100644 index 000000000..dc0b4a22e --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/debug/construct1_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010 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 +// . +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include +#include + +void test01() +{ + __gnu_test::check_construct1 >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/debug/construct2_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/debug/construct2_neg.cc new file mode 100644 index 000000000..13757a1fa --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/debug/construct2_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010 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 +// . +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include +#include + +void test01() +{ + __gnu_test::check_construct2 >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/debug/construct3_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/debug/construct3_neg.cc new file mode 100644 index 000000000..661af4382 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/debug/construct3_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010 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 +// . +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include +#include + +void test01() +{ + __gnu_test::check_construct3 >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/debug/construct4_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/debug/construct4_neg.cc new file mode 100644 index 000000000..ec33a5813 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/debug/construct4_neg.cc @@ -0,0 +1,32 @@ +// Copyright (C) 2010 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 +// . +// +// { dg-do run { xfail *-*-* } } + +#include +#include + +void test01() +{ + __gnu_test::check_construct1<__gnu_debug::vector >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/debug/insert1_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/debug/insert1_neg.cc new file mode 100644 index 000000000..2ec0d9e02 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/debug/insert1_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010 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 +// . +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include +#include + +void test01() +{ + __gnu_test::check_insert1 >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/debug/insert2_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/debug/insert2_neg.cc new file mode 100644 index 000000000..011ad4c0c --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/debug/insert2_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010 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 +// . +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include +#include + +void test01() +{ + __gnu_test::check_insert2 >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/debug/insert3_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/debug/insert3_neg.cc new file mode 100644 index 000000000..4dab133b5 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/debug/insert3_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010 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 +// . +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include +#include + +void test01() +{ + __gnu_test::check_insert3 >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/debug/insert4_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/debug/insert4_neg.cc new file mode 100644 index 000000000..684ebb598 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/debug/insert4_neg.cc @@ -0,0 +1,32 @@ +// Copyright (C) 2010 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 +// . +// +// { dg-do run { xfail *-*-* } } + +#include +#include + +void test01() +{ + __gnu_test::check_insert1<__gnu_debug::vector >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/debug/invalidation/1.cc b/libstdc++-v3/testsuite/23_containers/vector/debug/invalidation/1.cc new file mode 100644 index 000000000..0111efe48 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/debug/invalidation/1.cc @@ -0,0 +1,59 @@ +// Vector iterator invalidation tests + +// Copyright (C) 2003, 2004, 2005, 2006, 2009 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 +// . + +// We need to be pedantic about reallocations for this testcase to be correct. +// { dg-options "-D_GLIBCXX_DEBUG_PEDANTIC" } + +#ifndef _GLIBCXX_DEBUG_PEDANTIC +# define _GLIBCXX_DEBUG_PEDANTIC 1 +#endif + +#include +#include + +using __gnu_debug::vector; + +bool test = true; + +// Assignment +void test01() +{ + vector v1; + vector v2; + + vector::iterator i = v1.end(); + VERIFY(!i._M_dereferenceable() && !i._M_singular()); + + v1 = v2; + VERIFY(i._M_singular()); + + i = v1.end(); + v1.assign(v2.begin(), v2.end()); + VERIFY(i._M_singular()); + + i = v1.end(); + v1.assign(17, 42); + VERIFY(i._M_singular()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/debug/invalidation/2.cc b/libstdc++-v3/testsuite/23_containers/vector/debug/invalidation/2.cc new file mode 100644 index 000000000..9652ffb53 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/debug/invalidation/2.cc @@ -0,0 +1,64 @@ +// Vector iterator invalidation tests + +// Copyright (C) 2003, 2004, 2005, 2006, 2009 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 +// . + +// We need to be pedantic about reallocations for this testcase to be correct. +// { dg-options "-D_GLIBCXX_DEBUG_PEDANTIC" } + +#ifndef _GLIBCXX_DEBUG_PEDANTIC +# define _GLIBCXX_DEBUG_PEDANTIC 1 +#endif + +#include +#include + +using __gnu_debug::vector; + +bool test = true; + +// Resize +void test02() +{ + vector v(10, 17); + v.reserve(20); + + vector::iterator before = v.begin() + 6; + vector::iterator at = before + 1; + vector::iterator after = at + 1; + + // Shrink + v.resize(7); + VERIFY(before._M_dereferenceable()); + VERIFY(at._M_singular()); + VERIFY(after._M_singular()); + + // Grow, without reallocation + before = v.begin() + 6; + v.resize(17); + VERIFY(before._M_dereferenceable()); + + // Grow, with reallocation + v.resize(42); + VERIFY(before._M_singular()); +} + +int main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/debug/invalidation/3.cc b/libstdc++-v3/testsuite/23_containers/vector/debug/invalidation/3.cc new file mode 100644 index 000000000..df8759c52 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/debug/invalidation/3.cc @@ -0,0 +1,89 @@ +// Vector iterator invalidation tests + +// Copyright (C) 2003, 2004, 2005, 2006, 2009 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 +// . + +// We need to be pedantic about reallocations for this testcase to be correct. +// { dg-options "-D_GLIBCXX_DEBUG_PEDANTIC" } + +#ifndef _GLIBCXX_DEBUG_PEDANTIC +# define _GLIBCXX_DEBUG_PEDANTIC 1 +#endif + +#include +#include + +using __gnu_debug::vector; + +bool test = true; + +// Insert +void test03() +{ + vector v(10, 17); + v.reserve(30); + + // Insert a single element + vector::iterator before = v.begin() + 6; + vector::iterator at = before + 1; + vector::iterator after = at; + at = v.insert(at, 42); + VERIFY(before._M_dereferenceable()); + VERIFY(at._M_dereferenceable()); + VERIFY(after._M_singular()); + + // Insert multiple copies + before = v.begin() + 6; + at = before + 1; + v.insert(at, 3, 42); + VERIFY(before._M_dereferenceable()); + VERIFY(at._M_singular()); + + // Insert iterator range + static int data[] = { 2, 3, 5, 7 }; + before = v.begin() + 6; + at = before + 1; + v.insert(at, &data[0], &data[0] + 4); + VERIFY(before._M_dereferenceable()); + VERIFY(at._M_singular()); + + // Insert with reallocation + before = v.begin() + 6; + at = before + 1; + v.insert(at, 30, 17); + VERIFY(before._M_singular()); + VERIFY(at._M_singular()); + + // Single insert with reallocation + vector v2; + v2.reserve(100); + at = v2.begin(); + v2.insert(at, 100, 17); + at = v2.end() - 1; + before = v2.begin(); + VERIFY(at._M_dereferenceable()); + VERIFY(before._M_dereferenceable()); + at = v2.insert(at, 42); + VERIFY(at._M_dereferenceable()); + VERIFY(before._M_singular()); +} + +int main() +{ + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/debug/invalidation/4.cc b/libstdc++-v3/testsuite/23_containers/vector/debug/invalidation/4.cc new file mode 100644 index 000000000..569530693 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/debug/invalidation/4.cc @@ -0,0 +1,66 @@ +// Vector iterator invalidation tests + +// Copyright (C) 2003, 2004, 2005, 2006, 2009 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 +// . + +// We need to be pedantic about reallocations for this testcase to be correct. +// { dg-options "-D_GLIBCXX_DEBUG_PEDANTIC" } + +#ifndef _GLIBCXX_DEBUG_PEDANTIC +# define _GLIBCXX_DEBUG_PEDANTIC 1 +#endif + +#include +#include + +using __gnu_debug::vector; + +bool test = true; + +// Erase +void test04() +{ + vector v(20, 42); + + // Single element erase + vector::iterator before = v.begin(); + vector::iterator at = before + 3; + vector::iterator after = at; + at = v.erase(at); + VERIFY(before._M_dereferenceable()); + VERIFY(at._M_dereferenceable()); + VERIFY(after._M_singular()); + + // Multiple element erase + before = v.begin(); + at = before + 3; + v.erase(at, at + 3); + VERIFY(before._M_dereferenceable()); + VERIFY(at._M_singular()); + + // clear() + before = v.begin(); + VERIFY(before._M_dereferenceable()); + v.clear(); + VERIFY(before._M_singular()); +} + +int main() +{ + test04(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/debug/multithreaded_swap.cc b/libstdc++-v3/testsuite/23_containers/vector/debug/multithreaded_swap.cc new file mode 100644 index 000000000..b2a50aa21 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/debug/multithreaded_swap.cc @@ -0,0 +1,100 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-debug-mode "" } +// Copyright (C) 2010 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 +// . +// + +// This test check for potential deadlock when swaping sequences in debug +// mode as it requires acquiring 2 locks at the same time. + +#include +#include +#include +#include + +// The following function mimic the one in src/debug.cc to associate a mutex +// to a given safe sequence instance. +size_t +get_index(std::vector& v) +{ + const size_t mask = 0xf; + // We have to check the address of the internal safe sequence that starts + // after the normal vector memory footprint that is to say a 3 pointers + // offset: + void* __address = reinterpret_cast(&v) + 3 * sizeof(void*); + return std::_Hash_impl::hash(__address) & mask; +} + +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + vector v1, v2; + vector > > vs; + vector *pv3 = 0, *pv4 = 0; + const int nb_attempts = 100; + for (int i = 0; i != nb_attempts; ++i) + { + vs.push_back(shared_ptr >(new vector())); + if (!pv3) + { + if (get_index(*vs.back()) == get_index(v1)) + pv3 = vs.back().get(); + } + else if (!pv4) + { + if (get_index(*vs.back()) == get_index(v2)) + { + pv4 = vs.back().get(); + break; + } + } + } + + if (!pv3 || !pv4) + // Maybe an other time... + return; + + vector &v3 = *pv3, &v4 = *pv4; + + // v1 and v3 shares the same mutex instance, like v2 and v4 + // thread t1 lock v1 and v2 + thread t1([&v1, &v2]() + { + for (int i = 0; i != 1000; ++i) + v1.swap(v2); + }); + // thread t2 lock v4 and v3 + thread t2([&v3, &v4]() + { + for (int i = 0; i != 1000; ++i) + v4.swap(v3); + }); + t2.join(); + t1.join(); +} + +int main() +{ + test01(); + return 0; +} -- cgit v1.2.3