public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/97296] New: g++ accepts-invalid after DR2352 fix
@ 2020-10-05 18:55 mpolacek at gcc dot gnu.org
  2020-10-05 18:56 ` [Bug c++/97296] [10/11 Regression] " mpolacek at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-10-05 18:55 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 97296
           Summary: g++ accepts-invalid after DR2352 fix
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mpolacek at gcc dot gnu.org
  Target Milestone: ---

void f(const int * const &); // #1
void f(const int *); // #2
int *x;
int main()
{
  f(x);
}

has been accepted since r276058, but should be ambiguous.  The follow-up fix to
DR2352 (r276251) didn't make a difference for this test.

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

* [Bug c++/97296] [10/11 Regression] g++ accepts-invalid after DR2352 fix
  2020-10-05 18:55 [Bug c++/97296] New: g++ accepts-invalid after DR2352 fix mpolacek at gcc dot gnu.org
@ 2020-10-05 18:56 ` mpolacek at gcc dot gnu.org
  2020-11-19 18:11 ` mpolacek at gcc dot gnu.org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-10-05 18:56 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid
   Target Milestone|---                         |10.3
            Summary|g++ accepts-invalid after   |[10/11 Regression] g++
                   |DR2352 fix                  |accepts-invalid after
                   |                            |DR2352 fix

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

* [Bug c++/97296] [10/11 Regression] g++ accepts-invalid after DR2352 fix
  2020-10-05 18:55 [Bug c++/97296] New: g++ accepts-invalid after DR2352 fix mpolacek at gcc dot gnu.org
  2020-10-05 18:56 ` [Bug c++/97296] [10/11 Regression] " mpolacek at gcc dot gnu.org
@ 2020-11-19 18:11 ` mpolacek at gcc dot gnu.org
  2021-01-14  9:22 ` rguenth at gcc dot gnu.org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-11-19 18:11 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2020-11-19

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

* [Bug c++/97296] [10/11 Regression] g++ accepts-invalid after DR2352 fix
  2020-10-05 18:55 [Bug c++/97296] New: g++ accepts-invalid after DR2352 fix mpolacek at gcc dot gnu.org
  2020-10-05 18:56 ` [Bug c++/97296] [10/11 Regression] " mpolacek at gcc dot gnu.org
  2020-11-19 18:11 ` mpolacek at gcc dot gnu.org
@ 2021-01-14  9:22 ` rguenth at gcc dot gnu.org
  2021-02-12  3:07 ` jason at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-01-14  9:22 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2

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

* [Bug c++/97296] [10/11 Regression] g++ accepts-invalid after DR2352 fix
  2020-10-05 18:55 [Bug c++/97296] New: g++ accepts-invalid after DR2352 fix mpolacek at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2021-01-14  9:22 ` rguenth at gcc dot gnu.org
@ 2021-02-12  3:07 ` jason at gcc dot gnu.org
  2021-02-12  3:10 ` mpolacek at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jason at gcc dot gnu.org @ 2021-02-12  3:07 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org,
                   |                            |mpolacek at gcc dot gnu.org

--- Comment #1 from Jason Merrill <jason at gcc dot gnu.org> ---
Marek, since those were your changes, are you planning to take this one?

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

* [Bug c++/97296] [10/11 Regression] g++ accepts-invalid after DR2352 fix
  2020-10-05 18:55 [Bug c++/97296] New: g++ accepts-invalid after DR2352 fix mpolacek at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2021-02-12  3:07 ` jason at gcc dot gnu.org
@ 2021-02-12  3:10 ` mpolacek at gcc dot gnu.org
  2021-04-08 12:02 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-02-12  3:10 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |mpolacek at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Yeah, I'll take a look in the coming weeks.

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

* [Bug c++/97296] [10/11 Regression] g++ accepts-invalid after DR2352 fix
  2020-10-05 18:55 [Bug c++/97296] New: g++ accepts-invalid after DR2352 fix mpolacek at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2021-02-12  3:10 ` mpolacek at gcc dot gnu.org
@ 2021-04-08 12:02 ` rguenth at gcc dot gnu.org
  2022-04-13 12:42 ` [Bug c++/97296] [10/11/12 " cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-04-08 12:02 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|10.3                        |10.4

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 10.3 is being released, retargeting bugs to GCC 10.4.

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

* [Bug c++/97296] [10/11/12 Regression] g++ accepts-invalid after DR2352 fix
  2020-10-05 18:55 [Bug c++/97296] New: g++ accepts-invalid after DR2352 fix mpolacek at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2021-04-08 12:02 ` rguenth at gcc dot gnu.org
@ 2022-04-13 12:42 ` cvs-commit at gcc dot gnu.org
  2022-04-13 12:59 ` [Bug c++/97296] [10/11 " mpolacek at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-04-13 12:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:

https://gcc.gnu.org/g:85ae54e18b9a3cbe4feda921ecd77cf275177edf

commit r12-8138-g85ae54e18b9a3cbe4feda921ecd77cf275177edf
Author: Marek Polacek <polacek@redhat.com>
Date:   Tue Apr 12 17:30:30 2022 -0400

    c++: ambiguous call not diagnosed after DR2352 [PR97296]

    DR 2352 changed the definitions of reference-related (so that it uses
    "similar type" instead of "same type") and of reference-compatible (use
    a standard conversion sequence).  That means that reference-related is
    now more broad, which means that we will be binding more things directly.

    The original patch for DR 2352 caused some problems, which were fixed in
    r276251 by creating a "fake" ck_qual in direct_reference_binding, so
    that in

      void f(int *); // #1
      void f(const int * const &); // #2
      int *x;
      int main()
      {
        f(x); // call #1
      }

    we call #1.  The extra ck_qual in #2 causes compare_ics to select #1,
    which is a better match for "int *" because then we don't have to do
    a qualification conversion.

    Let's turn to the problem in this PR.  We have

      void f(const int * const &); // #1
      void f(const int *); // #2
      int *x;
      int main()
      {
        f(x);
      }

    We arrive in compare_ics to decide which one is better. The ICS for #1
    looks like

        ck_ref_bind      <-    ck_qual         <-   ck_identity
      const int *const &     const int *const         int *

    and the ICS for #2 is

        ck_qual     <-  ck_rvalue   <-  ck_identity
      const int *          int *           int *

    We strip the reference and then comp_cv_qual_signature when comparing two
    ck_quals sees that "const int *" is a proper subset of "const int *const"
    and we return -1.  But that's wrong; presumably the top-level "const"
    should be ignored and the call should be ambiguous.  This patch adjust
    the type of the "fake" ck_qual so that this problem doesn't arise.

            PR c++/97296

    gcc/cp/ChangeLog:

            * call.cc (direct_reference_binding): strip_top_quals when creating
            a ck_qual.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp0x/ref-bind4.C: Add dg-error.
            * g++.dg/cpp0x/ref-bind8.C: New test.

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

* [Bug c++/97296] [10/11 Regression] g++ accepts-invalid after DR2352 fix
  2020-10-05 18:55 [Bug c++/97296] New: g++ accepts-invalid after DR2352 fix mpolacek at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2022-04-13 12:42 ` [Bug c++/97296] [10/11/12 " cvs-commit at gcc dot gnu.org
@ 2022-04-13 12:59 ` mpolacek at gcc dot gnu.org
  2022-04-22 20:59 ` cvs-commit at gcc dot gnu.org
  2022-04-22 20:59 ` mpolacek at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-04-13 12:59 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[10/11/12 Regression] g++   |[10/11 Regression] g++
                   |accepts-invalid after       |accepts-invalid after
                   |DR2352 fix                  |DR2352 fix

--- Comment #5 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed on trunk so far, 11 is frozen at the moment.

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

* [Bug c++/97296] [10/11 Regression] g++ accepts-invalid after DR2352 fix
  2020-10-05 18:55 [Bug c++/97296] New: g++ accepts-invalid after DR2352 fix mpolacek at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2022-04-13 12:59 ` [Bug c++/97296] [10/11 " mpolacek at gcc dot gnu.org
@ 2022-04-22 20:59 ` cvs-commit at gcc dot gnu.org
  2022-04-22 20:59 ` mpolacek at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-04-22 20:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Marek Polacek
<mpolacek@gcc.gnu.org>:

https://gcc.gnu.org/g:47c74508116cb5959686b183374dfe97a5e4fb37

commit r11-9929-g47c74508116cb5959686b183374dfe97a5e4fb37
Author: Marek Polacek <polacek@redhat.com>
Date:   Tue Apr 12 17:30:30 2022 -0400

    c++: ambiguous call not diagnosed after DR2352 [PR97296]

    DR 2352 changed the definitions of reference-related (so that it uses
    "similar type" instead of "same type") and of reference-compatible (use
    a standard conversion sequence).  That means that reference-related is
    now more broad, which means that we will be binding more things directly.

    The original patch for DR 2352 caused some problems, which were fixed in
    r276251 by creating a "fake" ck_qual in direct_reference_binding, so
    that in

      void f(int *); // #1
      void f(const int * const &); // #2
      int *x;
      int main()
      {
        f(x); // call #1
      }

    we call #1.  The extra ck_qual in #2 causes compare_ics to select #1,
    which is a better match for "int *" because then we don't have to do
    a qualification conversion.

    Let's turn to the problem in this PR.  We have

      void f(const int * const &); // #1
      void f(const int *); // #2
      int *x;
      int main()
      {
        f(x);
      }

    We arrive in compare_ics to decide which one is better. The ICS for #1
    looks like

        ck_ref_bind      <-    ck_qual         <-   ck_identity
      const int *const &     const int *const         int *

    and the ICS for #2 is

        ck_qual     <-  ck_rvalue   <-  ck_identity
      const int *          int *           int *

    We strip the reference and then comp_cv_qual_signature when comparing two
    ck_quals sees that "const int *" is a proper subset of "const int *const"
    and we return -1.  But that's wrong; presumably the top-level "const"
    should be ignored and the call should be ambiguous.  This patch adjust
    the type of the "fake" ck_qual so that this problem doesn't arise.

            PR c++/97296

    gcc/cp/ChangeLog:

            * call.c (direct_reference_binding): strip_top_quals when creating
            a ck_qual.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp0x/ref-bind4.C: Add dg-error.
            * g++.dg/cpp0x/ref-bind8.C: New test.

    (cherry picked from commit 85ae54e18b9a3cbe4feda921ecd77cf275177edf)

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

* [Bug c++/97296] [10/11 Regression] g++ accepts-invalid after DR2352 fix
  2020-10-05 18:55 [Bug c++/97296] New: g++ accepts-invalid after DR2352 fix mpolacek at gcc dot gnu.org
                   ` (8 preceding siblings ...)
  2022-04-22 20:59 ` cvs-commit at gcc dot gnu.org
@ 2022-04-22 20:59 ` mpolacek at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-04-22 20:59 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

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

--- Comment #7 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed.

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

end of thread, other threads:[~2022-04-22 20:59 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-05 18:55 [Bug c++/97296] New: g++ accepts-invalid after DR2352 fix mpolacek at gcc dot gnu.org
2020-10-05 18:56 ` [Bug c++/97296] [10/11 Regression] " mpolacek at gcc dot gnu.org
2020-11-19 18:11 ` mpolacek at gcc dot gnu.org
2021-01-14  9:22 ` rguenth at gcc dot gnu.org
2021-02-12  3:07 ` jason at gcc dot gnu.org
2021-02-12  3:10 ` mpolacek at gcc dot gnu.org
2021-04-08 12:02 ` rguenth at gcc dot gnu.org
2022-04-13 12:42 ` [Bug c++/97296] [10/11/12 " cvs-commit at gcc dot gnu.org
2022-04-13 12:59 ` [Bug c++/97296] [10/11 " mpolacek at gcc dot gnu.org
2022-04-22 20:59 ` cvs-commit at gcc dot gnu.org
2022-04-22 20:59 ` mpolacek 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).