<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/70506>70506</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [libc++] `std::ranges::__movable_box` can overwrite data that comes after it
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            libc++
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
            huixie90
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          huixie90
      </td>
    </tr>
</table>

<pre>
    `std::ranges::__movable_box` can overwrite data that comes after it
this is similar to #68552
```cpp
struct A {
    A() {}

    double x{};
 bool y{};

    A(const A&) = default;
    A& operator=(const A&) = delete;
};

struct Test {
    Test() {}

 [[no_unique_address]] std::ranges::__movable_box<A> a;
    bool b = true;
};


int main(){
 static_assert(std::ranges::__doesnt_need_empty_state<A>);
    Test test;
    assert(test.b);
    test.a = std::ranges::__movable_box<A>{};
    assert(test.b);  // boom
}

```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVE2PmzAQ_TXDZbSR1wYCBw5JaX5B78iGSXBlcGoP291_XwHZzSZVqj1UQon17Dfz3vOHjtGeRqIKsj1I2U_21VIpQErI6kRP3PtQvaOJ8d1bBbmI3IHagdoFPZ4oruOmGfyLNo4a418hF9jqEf0Lhd_BMmGnWSP3mrH1A0XUR6aAlkHUIHbc24g2YrSDdTogewSp8iLL5LoAcrF-7fm8IpHD1DLuELb7FUFE3IEsQJYLuK0v3I_Zzk_GEb5eZtU70Xjv8O0OvS3a-jHyPMqX8qrGjo56cnytsq7M0Z8paPYBVP2A6Ijp2uevnhdrPyjyrbsZeWxw3sNsP_pmGu2viRrddYFihKyGrMYvbJr6tgP1HfWNpSUbswjnMP1L9vprR8ZB23HVeZUfWbNtGx0jhdnEAz2dpzhyMxJ1DQ1nfmtmIl20zRXVXSDIcyqf0Y8e88zG3JMWVC-OvhzK_Yl51AUR5AHkYY5tuAb1OaX3k5x0lepKVeqEque8LFJVFkolfZWpNC0yKY5EhUq3Zd62uTmWQqWie1ZHldhKCqmehdxKkQmlNiaXKpfp9thqVYjCQCpo0NZtnHsZNj6cEhvjRNVWZCJPnDbk4uXKO2takPvlWy59qGbSk5lOEVLhbOR4LcOW3fJYfKJlNf7nNyGZgqt65vNSZsnzZLmfzKb1A8jDLOfy93QO_ie1DPKwWIwgD4vLPwEAAP__7BhhoA">