https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102199
Bug ID: 102199 Summary: is_default_constructible incorrect for an inner type with NSDMI Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: eyalroz1 at gmx dot com Target Milestone: --- Stackoverflow discussion: https://stackoverflow.com/q/69050558/1593077 Related LLVM bug: https://bugs.llvm.org/show_bug.cgi?id=38374 GodBolt: https://godbolt.org/z/snPf7Ks4W Consider the following program: #include <type_traits> struct outer { struct inner { // inner() { } unsigned int x = 0; }; // static_assert(std::is_default_constructible<inner>::value, // "not default ctorable - inside"); }; static_assert(std::is_default_constructible<outer::inner>::value, "not default ctorable - outside"); It compiles. But if we uncomment the first static_assert - it evaluates to false. Mind you: Not because struct inner is incomplete; it is simply deemed to not be default-constructible. But - it _is_ default constructible. And if we add a method to struct outer which default-constructs an inner, it will work. Also note that if we uncomment the explicit default ctor the definition of struct inner, both asserts pass. clang++ seems to exhibit this too (also with -stdlib=libc++). I'm not sure whether this is an actual bug in the library, or whether the standard mandates this in some freakish way, but - it's just wrong.