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

            Bug ID: 116769
           Summary: Instantiation of defaulted default constructor with
                    non default constructible NDSMIs
           Product: gcc
           Version: 14.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dangelog at gmail dot com
  Target Milestone: ---

Hi,

Consider this testcase:


#include <type_traits>

struct NDC { NDC(int); };

template <typename T>
struct Wrap
{
    Wrap() = default;
    Wrap(const T &t) : t(t) {}
    T t = T();
};

static_assert(!std::is_default_constructible_v<Wrap<NDC>>);



GCC accepts this, while Clang / MSVC reject:
https://gcc.godbolt.org/z/njh6Tvj19

Is this supposed to be ill-formed instead? Wrap's default constructor is going
to be defined (and NOT deleted, https://eel.is/c++draft/class.default.ctor#2.5
should not apply here), and that should cause the =T() initialization for the
member to fail to compile.

Reply via email to