From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id ACCC2396DC11; Mon, 14 Jun 2021 20:17:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ACCC2396DC11 From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/100894] The std::common_reference implementation seems to be wrong Date: Mon, 14 Jun 2021 20:17:57 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: 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: redi at gcc dot gnu.org X-Bugzilla-Target-Milestone: 10.4 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: Mon, 14 Jun 2021 20:17:57 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D100894 --- Comment #2 from CVS Commits --- The master branch has been updated by Jonathan Wakely : https://gcc.gnu.org/g:c37b5ddcc88e0cc0f6a4ad609eda51021df0f6bb commit r12-1437-gc37b5ddcc88e0cc0f6a4ad609eda51021df0f6bb Author: Jonathan Wakely Date: Mon Jun 14 20:31:00 2021 +0100 libstdc++: Fix common_reference for non-reference results [PR100894] The result of COMMON-REF(A&, B&&) where they have no common reference type should not be a reference. The implementation of COMMON-REF fails to check that the result is a reference, so is well-formed when it shouldn't be. This means that common_reference uses that result when it shouldn't. The fix is to reject the result of COMMON-REF(A, B) if it's not a reference, so that common_reference falls through to the next case, which uses COND-RES, which yields a non-reference result. Signed-off-by: Jonathan Wakely libstdc++-v3/ChangeLog: PR libstdc++/100894 * include/std/type_traits (__common_ref_impl): Only use the type if it's a reference. * testsuite/20_util/common_reference/100894.cc: New test.=