diff options
author | Howard Hinnant <hhinnant@apple.com> | 2013-08-02 00:26:35 +0000 |
---|---|---|
committer | Howard Hinnant <hhinnant@apple.com> | 2013-08-02 00:26:35 +0000 |
commit | 42a3046eefdf86d762ab8a64642948a2bae93a05 (patch) | |
tree | d337103e276cba4b87375ac7053829afb8381d9e /libcxx/test/containers/sequences | |
parent | 1c349ef7e81f572ea66403ac5c3fd7750bf64f61 (diff) | |
download | bcm5719-llvm-42a3046eefdf86d762ab8a64642948a2bae93a05.tar.gz bcm5719-llvm-42a3046eefdf86d762ab8a64642948a2bae93a05.zip |
Ok, 3 major changes for debug mode in one commit:
1. I had been detecting and trapping iterator == and \!= among iterators
in different containers as an error. But the trapping itself is actually
an error.
Consider:
#include <iostream>
#include <vector>
#include <algorithm>
template <class C>
void
display(const C& c)
{
std::cout << "{";
bool first = true;
for (const auto& x : c)
{
if (\!first)
std::cout << ", ";
first = false;
std::cout << x;
}
std::cout << "}\n";
}
int
main()
{
typedef std::vector<int> V;
V v1 = {1, 3, 5};
V v2 = {2, 4, 6};
display(v1);
display(v2);
V::iterator i = std::find(v1.begin(), v1.end(), 1);
V::iterator j = std::find(v2.begin(), v2.end(), 2);
if (*i == *j)
i = j; // perfectly legal
// ...
if (i \!= j) // the only way to check
v2.push_back(*i);
display(v1);
display(v2);
}
It is legal to assign an iterator from one container to another of the
same type. This is required to work. One might want to test whether or
not such an assignment had been made. The way one performs such a check
is using the iterator's ==, \!= operator. This is a logical and necessary
function and does not constitute an error.
2. I had a header circular dependence bug when _LIBCPP_DEBUG2 is defined.
This caused a problem in several of the libc++ tests.
Fixed.
3. There is a serious problem when _LIBCPP_DEBUG2=1 at the moment in that
std::basic_string is inoperable. std::basic_string uses __wrap_iterator
to implement its iterators. __wrap_iterator has been rigged up in debug
mode to support vector. But string hasn't been rigged up yet. This means
that one gets false positives when using std::string in debug mode. I've
upped std::string's priority in www/debug_mode.html.
llvm-svn: 187636
Diffstat (limited to 'libcxx/test/containers/sequences')
-rw-r--r-- | libcxx/test/containers/sequences/list/db_iterators_1.pass.cpp | 54 | ||||
-rw-r--r-- | libcxx/test/containers/sequences/vector/db_iterators_1.pass.cpp | 54 |
2 files changed, 0 insertions, 108 deletions
diff --git a/libcxx/test/containers/sequences/list/db_iterators_1.pass.cpp b/libcxx/test/containers/sequences/list/db_iterators_1.pass.cpp deleted file mode 100644 index ae278f78756..00000000000 --- a/libcxx/test/containers/sequences/list/db_iterators_1.pass.cpp +++ /dev/null @@ -1,54 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <list> - -// Compare iterators from different containers with == or !=. - -#if _LIBCPP_DEBUG2 >= 1 - -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) - -#include <list> -#include <cassert> -#include <iterator> -#include <exception> -#include <cstdlib> - -#include "../../min_allocator.h" - -int main() -{ - { - typedef int T; - typedef std::list<T> C; - C c1; - C c2; - bool b = c1.begin() != c2.begin(); - assert(false); - } -#if __cplusplus >= 201103L - { - typedef int T; - typedef std::list<T, min_allocator<T>> C; - C c1; - C c2; - bool b = c1.begin() != c2.begin(); - assert(false); - } -#endif -} - -#else - -int main() -{ -} - -#endif diff --git a/libcxx/test/containers/sequences/vector/db_iterators_1.pass.cpp b/libcxx/test/containers/sequences/vector/db_iterators_1.pass.cpp deleted file mode 100644 index 1ef4a27a8a6..00000000000 --- a/libcxx/test/containers/sequences/vector/db_iterators_1.pass.cpp +++ /dev/null @@ -1,54 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <vector> - -// Compare iterators from different containers with == or !=. - -#if _LIBCPP_DEBUG2 >= 1 - -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) - -#include <vector> -#include <cassert> -#include <iterator> -#include <exception> -#include <cstdlib> - -#include "../../min_allocator.h" - -int main() -{ - { - typedef int T; - typedef std::vector<T> C; - C c1; - C c2; - bool b = c1.begin() != c2.begin(); - assert(false); - } -#if __cplusplus >= 201103L - { - typedef int T; - typedef std::vector<T, min_allocator<T>> C; - C c1; - C c2; - bool b = c1.begin() != c2.begin(); - assert(false); - } -#endif -} - -#else - -int main() -{ -} - -#endif |