debug container mutex association
Andreas Schwab
schwab@linux-m68k.org
Fri Dec 29 16:10:00 GMT 2017
On Sep 19 2016, François Dumont <frs.dumont@gmail.com> wrote:
> diff --git a/libstdc++-v3/testsuite/23_containers/vector/debug/mutex_association.cc b/libstdc++-v3/testsuite/23_containers/vector/debug/mutex_association.cc
> new file mode 100644
> index 0000000..a3c56e2
> --- /dev/null
> +++ b/libstdc++-v3/testsuite/23_containers/vector/debug/mutex_association.cc
> @@ -0,0 +1,42 @@
> +// Copyright (C) 2016 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 <set>
> +#include <debug/vector>
> +
> +#include <testsuite_hooks.h>
> +
> +class container : public __gnu_debug::_Safe_sequence<container>
> +{
> +public:
> + __gnu_cxx::__mutex&
> + get_mutex()
> + { return this->_M_get_mutex(); }
> +};
> +
> +int
> +main()
> +{
> + std::set<__gnu_cxx::__mutex*> mutexes;
> + container conts[17];
> +
> + for (int i = 0; i != 16; ++i)
> + VERIFY( mutexes.insert(&conts[i].get_mutex()).second );
There will be less than 16 unique mutexes, if sizeof(container) has more
trailing zero bits than alignof(__gnu_debug::vector<int>).
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
More information about the Libstdc++
mailing list