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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
GCC and EDG both reject this reduced version but Clang accepts it:

template<typename T>
struct uptr {
  uptr() { }
  ~uptr() { static_assert(sizeof(T), "complete type"); }
};

class S;

class Compiles
{
    uptr<S> s;
};

class DoesntCompile
{
    ~DoesntCompile();
    DoesntCompile();

    uptr<S> s{};
};

int main()
{
    return 0;
}

But if we remove the uptr() default constructor only EDG rejects it. If we use
a non-default constructor all three compilers reject it:

template<typename T>
struct uptr {
  uptr(void*) { }
  ~uptr() { static_assert(sizeof(T), "complete type"); }
};

class S;

class Compiles
{
    uptr<S> s;
};

class DoesntCompile
{
    ~DoesntCompile();
    DoesntCompile();

    uptr<S> s = nullptr;
};

int main()
{
    return 0;
}

Reply via email to