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

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <r...@gcc.gnu.org>:

https://gcc.gnu.org/g:d96db15967e78d7cecea3b1cf3169ceb924678ac

commit r12-220-gd96db15967e78d7cecea3b1cf3169ceb924678ac
Author: Jonathan Wakely <jwak...@redhat.com>
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 = 0;
      const int j = 0;
      std::pair<int, int> 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.

Reply via email to