From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 50D87385783E; Mon, 10 Oct 2022 18:59:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 50D87385783E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665428358; bh=XC0WLzvFmeJ3AuCXlBHcLAfEK0NLX7vqPUlSTs/UlZg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=jb+XrfZjp+UVayafeWIkrSywzNfqQZ3ehwZOXcN/tCpgNN1sStePBhxK5TMlMR1dE 2AYP8XSUwH5lqA86yQfQqG9n3mX43KEzbhbyXhFd+hvKP/0jQf3L2bdY7yGnw0t8kM HjFEWZXPjXtFm11oA0eGV6tkPe95qenwHKxsuxbU= From: "dcb314 at hotmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/92286] Possible improvement for -Wduplicated-cond warning Date: Mon, 10 Oct 2022 18:59:17 +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: 10.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: dcb314 at hotmail dot com X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: WONTFIX 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: 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=3D92286 David Binderman changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dcb314 at hotmail dot com --- Comment #4 from David Binderman --- Is there a simpler case which is worth addressing, where a condition is a simple opposite of a predecessor ? Something like: void f2( int a, int b) { if (a < b) g( a); else if (a >=3D b) g( b); else g( a + b); } Static analyser cppcheck can find this: feb23b.cc:20:13: style: Expression is always true because 'else if' conditi= on is opposite to previous condition at line 18. [multiCondition] else if (a >=3D b) ^ feb23b.cc:18:8: note: first condition if (a < b) ^ feb23b.cc:20:13: note: else if condition is opposite to first condition else if (a >=3D b) ^=