From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 00CCF38346B7; Fri, 10 Feb 2023 17:44:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 00CCF38346B7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1676051074; bh=a9qGlgWxoZbZHaJDx8Gpx0KWkqrHTp8LNJ3KgfPIRj4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=vVyTcxWSzz9spibPNQSJJaWRzlvN5k1G2lUVZ6Rl7Mr00+SFQjfrv/8z6c+7P8Pr6 YmDyoZ9q62nKZyuLIWXrjc9olioliuq3V2+8FiEmt1LAHvuVnDEom61IyB4NeyWq6F aO4kxAOCdE1+mKIwrG2wLWY25qKyNiDeq1j3wZ8o= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/107065] GCC treats rvalue as an lvalue Date: Fri, 10 Feb 2023 17:44:32 +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: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit 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: --- 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=3D107065 --- Comment #16 from CVS Commits --- The releases/gcc-12 branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:bc1ee711eeab4b0d55463cd153747d30c69225c7 commit r12-9127-gbc1ee711eeab4b0d55463cd153747d30c69225c7 Author: Jakub Jelinek Date: Thu Dec 15 19:17:45 2022 +0100 c++: Ensure !!var is not an lvalue [PR107065] The TRUTH_NOT_EXPR case in cp_build_unary_op is one of the spots where we somewhat fold immediately using invert_truthvalue_loc. I've tried using return build1_loc (location, TRUTH_NOT_EXPR, boolean_type_node, arg); in there instead, but unfortunately that regressed Wlogical-not-parentheses-*.c pr49706.c pr62199.c pr65120.c sequence-pt-= 1.C tests, so at least for backporting that doesn't seem to be a way to go. So, this patch instead wraps it into NON_LVALUE_EXPR if needed (which a= lso need a tweak for some tests in the pr47906.c test, but nothing major), with the intent to make it backportable, and later I'll try to do furth= er steps to avoid folding here prematurely. Most of the problems with build1 TRUTH_NOT_EXPR are that it doesn't even invert comparisons as mo= st common case and lots of warning code isn't able to deal with ! around comparisons; so perhaps one way to do this would be fold by hand only invertable comparisons and for the rest create TRUTH_NOT_EXPR. 2022-12-15 Jakub Jelinek PR c++/107065 gcc/cp/ * typeck.cc (cp_build_unary_op) : If invert_truthvalue_loc returns obvalue_p, wrap it into NON_LVALUE_EXPR. * parser.cc (cp_parser_binary_expression): Don't call warn_logical_not_parentheses if current.lhs is a NON_LVALUE_EXPR of a decl with boolean type. gcc/testsuite/ * g++.dg/cpp0x/pr107065.C: New test. (cherry picked from commit 8b775b4c48a3cc4ef5c50e56144aea02da2e9cc6)=