public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/102199] New: is_default_constructible incorrect for an inner type with NSDMI
@ 2021-09-04  9:30 eyalroz1 at gmx dot com
  2021-09-04 13:49 ` [Bug c++/102199] " pinskia at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: eyalroz1 at gmx dot com @ 2021-09-04  9:30 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-12-03 21:04 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-04  9:30 [Bug libstdc++/102199] New: is_default_constructible incorrect for an inner type with NSDMI eyalroz1 at gmx dot com
2021-09-04 13:49 ` [Bug c++/102199] " pinskia at gcc dot gnu.org
2021-09-04 14:01 ` pinskia at gcc dot gnu.org
2021-09-04 14:22 ` eyalroz1 at gmx dot com
2021-09-06 15:58 ` redi at gcc dot gnu.org
2021-09-06 19:39 ` eyalroz1 at gmx dot com
2021-09-06 19:54 ` eyalroz1 at gmx dot com
2021-09-08 10:13 ` redi at gcc dot gnu.org
2022-05-15  7:08 ` pinskia at gcc dot gnu.org
2023-12-03 21:04 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).