From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3C0193858D3C; Fri, 9 Jun 2023 15:21:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3C0193858D3C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686324113; bh=9H53t+dGyaSuenyLz392xDH9Q/XJK/YQu1FOqg/CPIs=; h=From:To:Subject:Date:From; b=l5foHHns0Jawyp0WtWUq34KjNLDgzkrpDbHMvRUZUBqoFWoFemXd8KKy5ScyfzUz0 4e2t3PY76wi/zSb5Zzha0qxVuG593mmZnJTALYVKbg0NYempKCCZYpw3vTEsyPvPGj DY4XwtzpzGEn5VNuUG/gc6ZMU+koT8DQ6jghlDpw= From: "jack.cui2 at foxmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/110195] New: defaulted constructor does not respect the private accessor Date: Fri, 09 Jun 2023 15:21:53 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 13.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jack.cui2 at foxmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D110195 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() =3D default; }; auto s1 =3D Single{}; // compiles fine with c++11,14,17. Compilation error = with c++20. Unexpected. auto s2 =3D Single(); // compilation error. expected behavior. Single s3; // compilation error. expected behavior. ---------------------------- but with class Single { private: explicit Single() =3D default; }; or class Single { private: Single() {} }; auto s1 =3D Single{}; // compilation error. expected behavior. auto s2 =3D Single(); // compilation error. expected behavior. Single s3; // compilation error. expected behavior.=