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

    <tr>
        <th>Summary</th>
        <td>
            Missing destructor call after assignment
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    Here is a minimal example that reproduces the issue: https://godbolt.org/z/EqdrWznfe

```c++
// DO_SOMETHING from the A destructor should be called when calling test()

void DO_SOMETHING();

struct A {
  A() {};
  // workaround 1
  // issue goes away with
  // A() = default;
  ~A() {
 DO_SOMETHING();
  }

  A & operator=(A a) & {
    return *this;
  }
};

// workaround 2: issue goes away if B is not a template
template<typename T>
struct B {
  void test() {
    // workaround 3
    //#ifdef __clang__
    //this->
    //#endif
 a = {};

    // workaround 4
    //a = decltype(a)();
 }

private:
  A a;
};

// look at disassembly of this function, it should include a call to DO_SOMETHING
void client(B<int> &f) {f.test();}
```

In essence, it assigns `{}` to a member variable, which should trigger the destruction of the old object.
The disassembly should include a call to  `DO_SOMETHING`, which it does for GCC, but not Clang. The example shows 4 possible workarounds, including changing `a = {}` to `this->a = {}` which then produces the expected call in disassembly.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8VU-Tm7gT_TTypWtcWDIMPnDwn3GSQ345_KZqjy6BGtBGSKwkxpkc9rNvSeAxZjepomaw1HS_1--pxZ2TjUYsSHog6WnFB98aW9iyRNugXZVGvBef0SJIBxw6qWXHFeAP3vUKwbfcg8XeGjFU6MC3IdANSNgeWu97R9ie0DOh58aI0ii_NrYh9PyT0PPLX8L-8VPXSJITSfbT3ywZn4rQQ3jG1ZgCTt8u___29eX185f_fYLami4W3INA5-1QeWPBtWZQAkqEiiuFAq4t6vgudQMenSc0J3Q3r_lmpHjIPYWwwzxqLAF7IM_TOs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