public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/95789] [10/11 Regression] Const method is allowed to return non-const reference on template class
Date: Tue, 14 Jul 2020 23:24:53 +0000	[thread overview]
Message-ID: <bug-95789-4-1eRE1GMqJR@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-95789-4@http.gcc.gnu.org/bugzilla/>

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

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

https://gcc.gnu.org/g:315b87f63bcde4c881e9963c39d57258da08ccb5

commit r10-8497-g315b87f63bcde4c881e9963c39d57258da08ccb5
Author: Marek Polacek <polacek@redhat.com>
Date:   Mon Jun 22 21:26:49 2020 -0400

    c++: Make convert_like complain about bad ck_ref_bind again [PR95789]

    convert_like issues errors about bad_p conversions at the beginning
    of the function, but in the ck_ref_bind case, it only issues them
    after we've called convert_like on the next conversion.

    This doesn't work as expected since r10-7096 because when we see
    a conversion from/to class type in a template, we return early, thereby
    missing the error, and a bad_p conversion goes by undetected.  That
    made the attached test to compile even though it should not.

    I had thought that I could just move the ck_ref_bind/bad_p errors
    above to the rest of them, but that regressed diagnostics because
    expr then wasn't converted yet by the nested convert_like_real call.

    So, for bad_p conversions, do the normal processing, but still return
    the IMPLICIT_CONV_EXPR to avoid introducing trees that the template
    processing can't handle well.  This I achieved by adding a wrapper
    function.

    gcc/cp/ChangeLog:

            PR c++/95789
            PR c++/96104
            PR c++/96179
            * call.c (convert_like_real_1): Renamed from convert_like_real.
            (convert_like_real): New wrapper for convert_like_real_1.

    gcc/testsuite/ChangeLog:

            PR c++/95789
            PR c++/96104
            PR c++/96179
            * g++.dg/conversion/ref4.C: New test.
            * g++.dg/conversion/ref5.C: New test.
            * g++.dg/conversion/ref6.C: New test.

    (cherry picked from commit 8e64d182850560dbedfabb88aac90d4fc6155067)

  parent reply	other threads:[~2020-07-14 23:24 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-20 18:23 [Bug c++/95789] New: " ivan at chebykin dot org
2020-06-21  9:03 ` [Bug c++/95789] [10/11 Regression] " redi at gcc dot gnu.org
2020-06-22 19:31 ` mpolacek at gcc dot gnu.org
2020-07-07 16:10 ` mpolacek at gcc dot gnu.org
2020-07-07 23:11 ` mpolacek at gcc dot gnu.org
2020-07-07 23:11 ` mpolacek at gcc dot gnu.org
2020-07-13 17:35 ` mpolacek at gcc dot gnu.org
2020-07-13 17:36 ` mpolacek at gcc dot gnu.org
2020-07-14 20:03 ` cvs-commit at gcc dot gnu.org
2020-07-14 23:24 ` cvs-commit at gcc dot gnu.org [this message]
2020-07-14 23:26 ` mpolacek at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-95789-4-1eRE1GMqJR@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).