public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "eyalroz1 at gmx dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/102199] New: is_default_constructible incorrect for an inner type with NSDMI
Date: Sat, 04 Sep 2021 09:30:22 +0000	[thread overview]
Message-ID: <bug-102199-4@http.gcc.gnu.org/bugzilla/> (raw)

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.

             reply	other threads:[~2021-09-04  9:30 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-04  9:30 eyalroz1 at gmx dot com [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-102199-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).