From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0116B3858D1E; Tue, 19 Mar 2024 11:43:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0116B3858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1710848629; bh=hwTGLVMJGhs92jMFmuos0IBUAlJVGLKxV89j4aJGYm0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=kWqmiFh4+E1/UDuiRk/Kpj7qaW/bOwUzlk23O0gpldVxPUwDpFzG4dZoMISWN7MLM Y/iMZM/hT1X/IC+ARxtwqWZxW6COjCzkwP52ZBamz7voDElTtoD+57hnZqI8kHPx6T LUn3vxVPMMsg9ltAU81UZ5MMqALVHK/79N/Zg2Lg= From: "de34 at live dot cn" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/114388] Behavioral change of typeid on xvalues since GCC 9 Date: Tue, 19 Mar 2024 11:43:48 +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: 9.5.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: de34 at live dot cn X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D114388 --- Comment #7 from Jiang An --- (In reply to Jonathan Wakely from comment #5) > Prior to DR 616 the expression (true ? WrapB().b : WrapD().d) was a prval= ue > of type B, created by copying the B (or slicing the D when the condition = is > false). As an rvalue, it wasn't evaluated. That's true pre-N3055 and > post-N3055. >=20 > DR 616 changed WrapB().b to be an xvalue, and the result of the expression > is B&& in C++1 (and const B& in C++98 I guess). >=20 > In C++98 the const B& is an lvalue, and in C++11 the B&& is an xvalue whi= ch > is a glvalue. Either way, it's correct to treat it as a glvalue of > polymorphic type and evaluate it. >=20 > So this change is not caused by N3055. And I think G++ is correct for both > C++98 and C++11. So INVALID. Pre-N3055 there were no xvalue branch in [expr.cond], and (later-called) xvalues were handled alongwith prvalues. I don't see anything in C++98 [expr.cond] adding const& when there's no const values. This example also shows that GCC hasn't been thinking that the result of the expression is const B& in C++98: https://godbolt.org/z/EPv65oY1W.=