[libcxx-commits] [libcxx] [libc++][ranges][abi-break] Fix `movable_box` overwriting memory of data that lives in the tail padding (PR #71314)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Dec 22 09:24:37 PST 2023
================
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+
+// Test that views that use __movable_box do not overwrite overlapping subobjects.
+
+#include <cassert>
+#include <ranges>
+
+struct Pred {
+ alignas(128) bool a{};
+
+ Pred() noexcept = default;
+ Pred(const Pred&) noexcept = default;
+ Pred(Pred&&) noexcept = default;
+
+ Pred& operator=(const Pred&) = delete;
+ Pred& operator=(Pred&&) = delete;
+
+ constexpr bool operator()(const auto&...) const { return true; }
+};
+
+struct View : std::ranges::view_base {
+ constexpr int* begin() const { return nullptr; }
+ constexpr int* end() const { return nullptr; }
+};
+
+template <class T>
+struct S {
+ [[no_unique_address]] T t{};
----------------
ldionne wrote:
```suggestion
[[no_unique_address]] View view{};
```
https://github.com/llvm/llvm-project/pull/71314
More information about the libcxx-commits
mailing list