From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 39462394481A; Wed, 28 Apr 2021 16:57:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 39462394481A From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/99957] Ill-formed std::pair construction supported Date: Wed, 28 Apr 2021 16:57:02 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed 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: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: 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, 28 Apr 2021 16:57:02 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99957 --- Comment #2 from CVS Commits --- The master branch has been updated by Jonathan Wakely : https://gcc.gnu.org/g:d96db15967e78d7cecea3b1cf3169ceb924678ac commit r12-220-gd96db15967e78d7cecea3b1cf3169ceb924678ac Author: Jonathan Wakely Date: Wed Apr 28 17:46:01 2021 +0100 libstdc++: Deprecate non-standard std::pair constructors [PR 99957] This deprecates the non-standard std::pair constructors that support construction from an rvalue and a literal zero used as a null pointer constant. We can't just add the deprecated attribute to those constructors, because they're currently used by correct code when they are a better match than the constructors required by the standard e.g. int i =3D 0; const int j =3D 0; std::pair p(i, j); // uses pair(U1&&, const int&) This patch adjusts the parameter types and constraints of those constructors so that they only get used for literal zeros, and the pair(U1&&, U2&&) constructor gets used otherwise. Once they're only used for initializations that should be ill-formed we can add the deprecated attribute. The deprecated attribute is used to suggest that the user code uses nullptr, which avoids the problem of 0 deducing as int instead of a null pointer constant. libstdc++-v3/ChangeLog: PR libstdc++/99957 * include/bits/stl_pair.h (_PCC::_MoveCopyPair, _PCC::_CopyMovePair): Combine and replace with ... (_PCC::_DeprConsPair): New SFINAE helper function. (pair): Merge preprocessor blocks so that all C++03 members are defined together at the end. (pair::pair(const _T1&, _U2&&), pair::pair(_U1&&, const _T2&)): Replace _T1 and _T2 parameters with __null_ptr_constant and adjust constraints. * testsuite/20_util/pair/40925.cc: Use nullptr instead of 0. * testsuite/20_util/pair/cons/explicit_construct.cc: Likewise. * testsuite/20_util/pair/cons/99957.cc: New test.=