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

    <tr>
        <th>Summary</th>
        <td>
            Instantiating a destructor for a template class too early, before the calling destructor is seen - rejects valid code
        </td>
    </tr>

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

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

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

<pre>
    The following code is rejected as trying to use incomplete type, while when the actual use would actually appear the type would be complete:

template<typename T>
struct uptr {
    uptr(nullptr_t) {}
    ~uptr() {
        delete (new T);
    }
};

class A
{
public:
  A();
  ~A();
private:
  class B;
  uptr<B> m_b = nullptr; // the dtor of uptr tries to be instantiated here
};

If we change the initialization of:
uptr<B> m_b = nullptr; 
To:
uptr<B> m_b {nullptr}; 

The destructor instantiation is delayed, till ~A() is seen, and the code can be compiled.

See:
https://stackoverflow.com/questions/71397495/why-does-default-member-initializer-request-instantiation-of-unique-ptr-destru
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyFVE2PmzAQ_TVwGRERk4Rw4NBsttKeu_eVwUNw12Bqm0Tpr-_YQEIrrYoSZ5gvv3kzk0qLe_neIjRaKX2T_QVqLRCkBYM_sXYogFtw5u5NTsNoydjXuhsUOgR3HzBiL3BrpUI6sQdH2XjtRq6C802PSswKdQc-DMhNcPKxs7lCWFJG2bcoPUfpfDokNffqF-_f8w7hPcpeJ6t1ZqwdjIMzEOWnSQn0eE3Ejv2oFEkfLmJFcMjPT58of53dFuvD5B-BoUKfBW90Jyui7LSOnlN5YTFMZ624tbCUseQdxkrJ-lEekEO4eZWVEP2rHIy88hUrAFP20yosVJG9kOoVuo8KouwMc-XkRRV8p0-gXDhtQDcTYc5ItL6nlW-pdbx3kvuGt2jwq9reGrhRs1reXzCklL2kMCV_cyd1T8kfUP8HKzi966_989PiHmDAGoefWYFT_6mmJ34PgqaXusfvKPxsOqnUilpvtYi9N_FehCLCzNe8XwaRhlls1tf9wGcLWucG698Cr3Rv_amvaBranw0Fk-7XSMgIiCU532ZFviv2JN7aeyI02kRgw0flkg67Ck3yoJBkgyE4-augRDfJ2EuyJMRGMtUdizITRVbw2EmnsHx7RtCq8jU7DX05LKs0T5DTGmgV1d0TUSH5TA2taU99hjW7E2OQzH8KFq4EVwTa4tGo8m9KLtK1YzVzodR1-UkGo304vUprqUwS9jt23MdtidttXomtOBzSQ1bUh6LOeLPL2YHl4ih2aax4hcqW0f4UMeY3MqQgOdqfY1mylLE0S48so2e7ydhui4f0yAUjjo55tEux41JtPI6NNpfYlAFSNV4sGZW0zj6NxI-89IjhOsrPR9dqU35KY1veSROHy8sA_g-IpKZq">