From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E08C73858005; Wed, 29 Nov 2023 15:51:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E08C73858005 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1701273113; bh=p9MYbxeqSEffb2CI3sjZKNHrNia142pTuFcIsa40gGM=; h=From:To:Subject:Date:From; b=t8EM9c5kOHfeoBaGpjWXVBeH2lcOmgf3V6jF8OpB4QVaRznUD9XVq7O4knhVYHmyz Tpb7gFwhyM64tTfNFPf7p1tj3uGeLk+bhBglfXMm77MOT0miz3FEhTJJmVA+pOsRHj P0ima/5+k4q6A3lynhQgQ3tRjcWOgAm9R3R3leMo= From: "sss@li-snyder.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/112765] New: [14 regression] -Wparentheses warning even when extra parens are present Date: Wed, 29 Nov 2023 15:51:53 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: sss@li-snyder.org 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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=3D112765 Bug ID: 112765 Summary: [14 regression] -Wparentheses warning even when extra parens are present Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: sss@li-snyder.org Target Milestone: --- hi - With a recent checkout of gcc14 (20231129), on a x86_64-pc-linux-gnu host, the following source gives a bogus -Wparentheses warning with -Wall: -------------------------------------------------------------- struct ptr { ptr& operator=3D (ptr&& __u); explicit operator bool() const; }; ptr getShare (); template class AnaToolHandle final { public: int getMode (ptr& sharedTool) const; }; template int AnaToolHandle::getMode (ptr& sharedTool) const { if ((sharedTool =3D getShare ())) return 0; return 1; } void initialize(AnaToolHandle& jetCleaningTool) { ptr sharedTool; jetCleaningTool.getMode (sharedTool); } -------------------------------------------------------------- $ g++ -c -Wall x.cc x.cc: In instantiation of =E2=80=98int AnaToolHandle::getMode(ptr&) cons= t [with T =3D int]=E2=80=99: x.cc:28:27: required from here 28 | jetCleaningTool.getMode (sharedTool); | ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~ x.cc:19:31: warning: suggest parentheses around assignment used as truth va= lue [-Wparentheses] 19 | if ((sharedTool =3D getShare ())) | ^ It is true that there is an assignment used as a truth value, and in the original code this was intentional, which the author signalled by adding an extra pair of parentheses. However, gcc emits the warning even though the extra parentheses are there. (Adding yet another pair of parentheses around the condition does not silence the warning.) This warning does not occcur with gcc 13.2.1 20230728.=