From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C70CE3858028; Wed, 7 Apr 2021 12:44:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C70CE3858028 From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/99957] New: Ill-formed std::pair construction supported Date: Wed, 07 Apr 2021 12:44:52 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: accepts-invalid X-Bugzilla-Severity: minor X-Bugzilla-Who: redi at gcc dot gnu.org 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 keywords 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Apr 2021 12:44:52 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99957 Bug ID: 99957 Summary: Ill-formed std::pair construction supported Product: gcc Version: 11.0 Status: UNCONFIRMED Keywords: accepts-invalid Severity: minor Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: redi at gcc dot gnu.org Target Milestone: --- This shouldn't compile: #include struct move_only { move_only() =3D default; move_only(move_only&&) =3D default; }; move_only mo() { return {}; } std::pair p0(0, mo()); std::pair p1({}, mo()); According to the standard, these constructors are considered: pair(const first_type&, const second_type&); template pair(U1&&, U2&&); For both p0 and p1, the first does not participate in overload resolution because second_type is not copy constructible. For p0, the second constructor does not participate because U1 is deduced as int, and a pointer cannot be constructed from int. For p1, U1 cannot be ded= uced from {}. The code compiles with libstdc++ because we have additional non-standard constructors, added by PR 40925 and described in https://gcc.gnu.org/pipermail/libstdc++/2021-April/052299.html (where I proposed to deprecate these non-standard constructors, and eventually remove them).=