https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104850

--- Comment #2 from Amir Kirsh <kirshamir at gmail dot com> ---
// adding the required include to the example

#include <cstddef> // for nullptr_t

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
};

https://wandbox.org/permlink/rJeeB3Sliey6tGzR

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

Relevant SO post:
https://stackoverflow.com/questions/71397495/why-does-default-member-initializer-request-instantiation-of-unique-ptr-destru/71402270#71402270

Reply via email to