In the following code an object is overwritten with a new object of same type, where a lambda-expression creates a closure that uses `this` of the old object. The old address (`this`) remains the same, the new object has the same layout, so this should be ok and not UB. But what about non trivial objects or other cases?

```
struct A {
    void g(A& o, int v) {
        o = A{.x = v, .f = [this]{
            std::cout << "f" << this->x << '\n';
        }};
    }
    int x{0};
    std::function<void()> f;
    ~A() {
        std::cout << "dtor" << x << '\n';
    }
};

void test() {
    A a;
    a.g(a, 2);
    a.f();
}

```