public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/101124] New: [12 Regression] pair<T*, int>(0, 0) was intended to be deprecated, but is rejected now
@ 2021-06-18 13:33 redi at gcc dot gnu.org
  2021-06-21  6:15 ` [Bug libstdc++/101124] " rguenth at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2021-06-18 13:33 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libstdc++/101124] [12 Regression] pair<T*, int>(0, 0) was intended to be deprecated, but is rejected now
  2021-06-18 13:33 [Bug libstdc++/101124] New: [12 Regression] pair<T*, int>(0, 0) was intended to be deprecated, but is rejected now redi at gcc dot gnu.org
@ 2021-06-21  6:15 ` rguenth at gcc dot gnu.org
  2021-09-25 20:08 ` redi at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-06-21  6:15 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
   Target Milestone|---                         |12.0

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libstdc++/101124] [12 Regression] pair<T*, int>(0, 0) was intended to be deprecated, but is rejected now
  2021-06-18 13:33 [Bug libstdc++/101124] New: [12 Regression] pair<T*, int>(0, 0) was intended to be deprecated, but is rejected now redi at gcc dot gnu.org
  2021-06-21  6:15 ` [Bug libstdc++/101124] " rguenth at gcc dot gnu.org
@ 2021-09-25 20:08 ` redi at gcc dot gnu.org
  2022-01-17 14:26 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2021-09-25 20:08 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2021-09-25
             Status|UNCONFIRMED                 |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |redi at gcc dot gnu.org

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libstdc++/101124] [12 Regression] pair<T*, int>(0, 0) was intended to be deprecated, but is rejected now
  2021-06-18 13:33 [Bug libstdc++/101124] New: [12 Regression] pair<T*, int>(0, 0) was intended to be deprecated, but is rejected now redi at gcc dot gnu.org
  2021-06-21  6:15 ` [Bug libstdc++/101124] " rguenth at gcc dot gnu.org
  2021-09-25 20:08 ` redi at gcc dot gnu.org
@ 2022-01-17 14:26 ` rguenth at gcc dot gnu.org
  2022-01-18 11:11 ` redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-01-17 14:26 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libstdc++/101124] [12 Regression] pair<T*, int>(0, 0) was intended to be deprecated, but is rejected now
  2021-06-18 13:33 [Bug libstdc++/101124] New: [12 Regression] pair<T*, int>(0, 0) was intended to be deprecated, but is rejected now redi at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2022-01-17 14:26 ` rguenth at gcc dot gnu.org
@ 2022-01-18 11:11 ` redi at gcc dot gnu.org
  2022-01-18 16:32 ` cvs-commit at gcc dot gnu.org
  2022-01-18 16:37 ` redi at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2022-01-18 11:11 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Another example that now fails:

#include <utility>
struct X { } x;
std::pair<const X, void*> p(x, 0);

This selects the pair<T1,T2>::pair<U1,U2>(U1&&, U2&&) constructor, because x is
non-const and the pair<T1,T2>::first_type type is const. U2 gets deduced as
int, and int cannot convert to a pointer.

This code is just wrong and the standard says it should not compile, it should
be fixed to use p(x, nullptr).

p(std::as_const(x), 0) would also work, but is gross. Just use nullptr.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libstdc++/101124] [12 Regression] pair<T*, int>(0, 0) was intended to be deprecated, but is rejected now
  2021-06-18 13:33 [Bug libstdc++/101124] New: [12 Regression] pair<T*, int>(0, 0) was intended to be deprecated, but is rejected now redi at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2022-01-18 11:11 ` redi at gcc dot gnu.org
@ 2022-01-18 16:32 ` cvs-commit at gcc dot gnu.org
  2022-01-18 16:37 ` redi at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-01-18 16:32 UTC (permalink / raw)
  To: gcc-bugs

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

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

https://gcc.gnu.org/g:302343d8dd30e34516f74a61ec758d80a6c4d1db

commit r12-6691-g302343d8dd30e34516f74a61ec758d80a6c4d1db
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Jan 18 15:10:06 2022 +0000

    libstdc++: Fix ambiguous std::pair constructors [PR101124]

    The deprecated non-standard std::pair constructors that allow
    constructing std::pair<move-only-type, pointer-type> from an rvalue and
    a literal zero where not sufficiently constrained. They were viable when
    constructing std::pair<copyable-type, pointer-type>, and that case
    should work fine using the standard constructors.

    Replace the constraints on the non-standard constructors so they are
    only viable in cases that should actually be ill-formed according to the
    standard.

    Also rename __null_ptr_constant to __zero_as_null_pointer_constant so it
    matches the name of the -Wzero-as-null-pointer-constant warning. Also
    make the text of the deprecated warning describe the problem in more
    detail.

    libstdc++-v3/ChangeLog:

            PR libstdc++/101124
            * include/bits/stl_pair.h (pair): Adjust constraints on
            deprecated constructors accepting literal zero as null pointer
            constant. Improve wording of deprecated attribute.
            * testsuite/20_util/pair/cons/99957.cc: Check that deprecated
            constructors do not cause ambiguities for copyable types.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libstdc++/101124] [12 Regression] pair<T*, int>(0, 0) was intended to be deprecated, but is rejected now
  2021-06-18 13:33 [Bug libstdc++/101124] New: [12 Regression] pair<T*, int>(0, 0) was intended to be deprecated, but is rejected now redi at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2022-01-18 16:32 ` cvs-commit at gcc dot gnu.org
@ 2022-01-18 16:37 ` redi at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2022-01-18 16:37 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-01-18 16:37 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-18 13:33 [Bug libstdc++/101124] New: [12 Regression] pair<T*, int>(0, 0) was intended to be deprecated, but is rejected now redi at gcc dot gnu.org
2021-06-21  6:15 ` [Bug libstdc++/101124] " rguenth at gcc dot gnu.org
2021-09-25 20:08 ` redi at gcc dot gnu.org
2022-01-17 14:26 ` rguenth at gcc dot gnu.org
2022-01-18 11:11 ` redi at gcc dot gnu.org
2022-01-18 16:32 ` cvs-commit at gcc dot gnu.org
2022-01-18 16:37 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).