From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id F0AE3384607A; Tue, 14 Jul 2020 20:03:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F0AE3384607A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1594757022; bh=E4T3NyZUBDl0etLTJjYAzBlbDViKYm0HvbL5+pBhWeE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=IZ9DFqbzMLirD2r4O99oGOQjEBkDK3EGlOs0/xZ8JVUy8fgFKCOanRPp+wnPR7PX7 pFntyi6vBy4PG5himKDtPS8knNHJSy0klFGHnQ8r8H8zLGiK1AByNjjJHWUNVgsk7e Gpm6ZxDcbNRmCnWTegudl8Yw5GDdfZDLze8hsGuY= From: "cvs-commit at gcc dot 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 20:03:42 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 10.1.0 X-Bugzilla-Keywords: accepts-invalid X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: mpolacek at gcc dot gnu.org X-Bugzilla-Target-Milestone: 10.2 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Jul 2020 20:03:43 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95789 --- Comment #8 from CVS Commits --- The master branch has been updated by Marek Polacek : https://gcc.gnu.org/g:8e64d182850560dbedfabb88aac90d4fc6155067 commit r11-2097-g8e64d182850560dbedfabb88aac90d4fc6155067 Author: Marek Polacek 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.=