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

            Bug ID: 101124
           Summary: [12 Regression] pair<T*, int>(0, 0) was intended to be
                    deprecated, but is rejected now
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

r12-220-gd96db15967e78d7cecea3b1cf3169ceb924678ac intended to deprecate the
non-standard constructors allowing this:

#include <utility>
std::pair<long*, int> p(0, 0);

However, as reported in PR 100375 the hack doesn't work, and it triggers a
warning (which is an error with -Wpedantic):

pair.C:2:29: warning: ISO C++ says that these are ambiguous, even though the
worst conversion for the first is better than the worst conversion for the
second:
    2 | std::pair<long*, int> p(0, 0);
      |                             ^
In file included from /home/jwakely/gcc/12/include/c++/12.0.0/utility:70,
                 from pair.C:1:
/home/jwakely/gcc/12/include/c++/12.0.0/bits/stl_pair.h:426:17: note: candidate
1: 'constexpr std::pair<_T1, _T2>::pair(const _T1&, const _T2&) [with _U1 =
long int*; _U2 = int; typename std::enable_if<(std::_PCC<true, _T1,
_T2>::_ConstructiblePair<_U1, _U2>() && std::_PCC<true, _T1,
_T2>::_ImplicitlyConvertiblePair<_U1, _U2>()), bool>::type <anonymous> = true;
_T1 = long int*; _T2 = int]'
  426 |       constexpr pair(const _T1& __a, const _T2& __b)
      |                 ^~~~
/home/jwakely/gcc/12/include/c++/12.0.0/bits/stl_pair.h:511:18: note: candidate
2: 'constexpr std::pair<_T1, _T2>::pair(std::pair<_T1,
_T2>::__null_ptr_constant, _U2&&) [with _U2 = int; typename std::enable_if<((!
std::__or_<std::is_same<_U2, const _T2&>, std::is_same<_U2, _T2&> >::value) &&
std::_PCC<true, _T1, _T2>::_DeprConsPair<true, std::nullptr_t, _U2>()),
bool>::type <anonymous> = true; _T1 = long int*; _T2 = int]'
  511 |        constexpr pair(__null_ptr_constant, _U2&& __y)
      |                  ^~~~


Maybe this is OK, because it's a non-standard feature and so rejecting it with
-Wpedantic might be OK. But my intention was to accept it with a deprecation
warning for GCC 12, and only make it ill-formed for GCC 13.

I need to see if it's possible to make it work as intended, and if not then
just remove the hack and make it ill-formed for GCC 12.

Reply via email to