public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/110195] New: defaulted constructor does not respect the private accessor
@ 2023-06-09 15:21 jack.cui2 at foxmail dot com
  2023-06-09 15:27 ` [Bug c++/110195] " pinskia at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: jack.cui2 at foxmail dot com @ 2023-06-09 15:21 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110195
           Summary: defaulted constructor does not respect the private
                    accessor
           Product: gcc
           Version: 13.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jack.cui2 at foxmail dot com
  Target Milestone: ---

class Single
{
private:
    Single() = default;
};

auto s1 = Single{}; // compiles fine with c++11,14,17. Compilation error with
c++20. Unexpected.
auto s2 = Single(); // compilation error. expected behavior.
Single s3;          // compilation error. expected behavior.

----------------------------
but with

class Single
{
private:
    explicit Single() = default;
};

or

class Single
{
private:
    Single() {}
};

auto s1 = Single{}; // compilation error. expected behavior.
auto s2 = Single(); // compilation error. expected behavior.
Single s3;          // compilation error. expected behavior.

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

end of thread, other threads:[~2023-06-10  8:18 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-09 15:21 [Bug c++/110195] New: defaulted constructor does not respect the private accessor jack.cui2 at foxmail dot com
2023-06-09 15:27 ` [Bug c++/110195] " pinskia at gcc dot gnu.org
2023-06-09 15:35 ` jack.cui2 at foxmail dot com
2023-06-09 16:10 ` jack.cui2 at foxmail dot com
2023-06-09 16:13 ` pinskia at gcc dot gnu.org
2023-06-09 16:19 ` jack.cui2 at foxmail dot com
2023-06-09 20:52 ` redi at gcc dot gnu.org
2023-06-10  1:25 ` jack.cui2 at foxmail dot com
2023-06-10  8:18 ` redi 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).