[libcxx-commits] [libcxx] [libc++] Validate exception throwing for vector mutators on max_size violation (PR #131953)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jun 18 09:52:26 PDT 2025
================
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// UNSUPPORTED: no-exceptions
+
+// <vector>
+
+// template<container-compatible-range<T> R>
+// constexpr void append_range(R&& rg); // C++23
+
+#include <cassert>
+#include <vector>
+
+#include "../../insert_range_sequence_containers.h"
+#include "test_allocator.h"
+
+void test() {
+ test_append_range_exception_safety_throwing_copy<std::vector>();
+ test_append_range_exception_safety_throwing_allocator<std::vector, int>();
+
+ {
+ std::vector<int, limited_allocator<int, 10> > v(8, 42);
+ int a[] = {1, 2, 3};
+ try {
+ v.append_range(a);
+ assert(false);
+ } catch (...) {
----------------
ldionne wrote:
Is there a reason why you're catching `...` instead of catching `std::length_error const&` (I think)?
Applies elsewhere.
https://github.com/llvm/llvm-project/pull/131953
More information about the libcxx-commits
mailing list