From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 23EEF385841A; Tue, 30 Aug 2022 17:02:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 23EEF385841A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1661878947; bh=IR//Fzs0NlHiNVgxeFBh/DCoM3c4mZ9G20xKFHvHqts=; h=From:To:Subject:Date:In-Reply-To:References:From; b=bDpwwW+8aEkYvYT+KbnsJkExWhYY0JrVNOV5IDnuO99OXIEwvvWQtQGWDBBZDVwA1 iE82ERZnqs2MsiqdwqK4Mw8m7GLWLvWScJHLlLaTdoVoBJk9otb5gcNTrso4L0N471 B4LDgCBBnmYFJ9CGGwQQwhtxy7s2OsypoOzYoqhI= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/106775] [10/11/12/13 regression] Subscipt operator with array rvalue inside brackets returns lvalue Date: Tue, 30 Aug 2022 17:02:26 +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: 12.2.0 X-Bugzilla-Keywords: accepts-invalid X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 11.4 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc 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=3D106775 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jason at gcc dot gnu.org --- Comment #3 from Jakub Jelinek --- So, perhaps either we need to in the 556 if (swapped 557 && flag_strong_eval_order =3D=3D 2 558 && (TREE_SIDE_EFFECTS (array_expr) || TREE_SIDE_EFFECTS (index_exp))) 559 expr =3D build_array_ref (input_location, index_exp, array_= expr); 560 else 561 expr =3D build_array_ref (input_location, array_expr, index= _exp); spot if array_expr has ARRAY_TYPE and is xvalue rather than lvalue choose some different representation which will ensure the side-effects are evaluated in the right order, perhaps by using save_expr around index_exp a= nd using COMPOUND_EXPR for that save_expr and array_expr, or need to adjust lvalue_kind so that it is able to recognize even what we lower the array re= f to in the line 559 case as array ref with ARRAY_TYPE xvalue base. We actually lower it as *(x + y) instead of x[y] with ensuring the side-effects being evaluated in the right order.=