diff options
| author | Louis Dionne <ldionne@apple.com> | 2019-09-05 13:50:28 +0000 |
|---|---|---|
| committer | Louis Dionne <ldionne@apple.com> | 2019-09-05 13:50:28 +0000 |
| commit | b370e7691a680b06f3c159c6a19582adf449de90 (patch) | |
| tree | 91b25bb05f37b2524aca773de335ce2e0c8f9662 /libcxx/test | |
| parent | f1b4eba66fb60dc3c6058041a0149883a02383ae (diff) | |
| download | bcm5719-llvm-b370e7691a680b06f3c159c6a19582adf449de90.tar.gz bcm5719-llvm-b370e7691a680b06f3c159c6a19582adf449de90.zip | |
[libc++] Revert "Make `vector` unconditionally move elements when exceptions are disabled."
This reverts r370502, which broke the use case of a copy-only T (with a
deleted move constructor) when exceptions are disabled. Until we figure
out the right behavior, I'm reverting the commit.
llvm-svn: 371068
Diffstat (limited to 'libcxx/test')
| -rw-r--r-- | libcxx/test/libcxx/containers/sequences/vector/exception_safety_exceptions_disabled.sh.cpp | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/libcxx/test/libcxx/containers/sequences/vector/exception_safety_exceptions_disabled.sh.cpp b/libcxx/test/libcxx/containers/sequences/vector/exception_safety_exceptions_disabled.sh.cpp deleted file mode 100644 index 1e9cbde0114..00000000000 --- a/libcxx/test/libcxx/containers/sequences/vector/exception_safety_exceptions_disabled.sh.cpp +++ /dev/null @@ -1,57 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// RUN: %build -fno-exceptions -// RUN: %run - -// UNSUPPORTED: c++98, c++03 - -// <vector> - -// Test that vector always moves elements when exceptions are disabled. -// vector is allowed to move or copy elements while resizing, so long as -// it still provides the strong exception safety guarantee. - -#include <vector> -#include <cassert> - -#include "test_macros.h" - -#ifndef TEST_HAS_NO_EXCEPTIONS -#error exceptions should be disabled. -#endif - -bool allow_moves = false; - -class A { -public: - A() {} - A(A&&) { assert(allow_moves); } - explicit A(int) {} - A(A const&) { assert(false); } -}; - -int main(int, char**) { - std::vector<A> v; - - // Create a vector containing some number of elements that will - // have to be moved when it is resized. - v.reserve(10); - size_t old_cap = v.capacity(); - for (int i = 0; i < v.capacity(); ++i) { - v.emplace_back(42); - } - assert(v.capacity() == old_cap); - assert(v.size() == v.capacity()); - - // The next emplace back should resize. - allow_moves = true; - v.emplace_back(42); - - return 0; -} |

