From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C39013858D39; Thu, 18 Apr 2024 07:47:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C39013858D39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1713426432; bh=yAkVYWQA/CoVJT5FSRSpeVW3FNDlCXYzJxNh2KvurNM=; h=From:To:Subject:Date:From; b=NvBCGp4g/hYZnkThBA/lRwJcSPDRTgzC1EYPydifQ33iWVsVwlKzAzf1il49uz0UC L8yJ0a9toCKjFfvvaPPs7su4LbZVbGhOFy08aReOYAr0w58bAdEGIKVxCZO9+Ew9FZ bytu1nylxT3VCwBKMkLWsPqH9SG1LBdGYmXu7gao= From: "hanwei62 at huawei dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/114763] New: Wduplicated-branches just check last else if-else case? Date: Thu, 18 Apr 2024 07:47:12 +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: hanwei62 at huawei dot com 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=3D114763 Bug ID: 114763 Summary: Wduplicated-branches just check last else if-else case? Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: hanwei62 at huawei dot com Target Milestone: --- This code: void foo(int x) { if (x) { x -=3D 2; } else if (x > 50) { x -=3D 2; } else x +=3D 2; } # gcc -c test.c -Wduplicated-branches not warning, even if-else if branches is same. void foo(int x) { if (x) { x -=3D 2; } else if (x > 50) { x -=3D 2; } else if (x < 20) { x +=3D 2; } else { x +=3D 2; } } warning. Same like https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D85094 What I find that Wduplicated-branches just check the last `else if-else` branches. https://godbolt.org/z/WP8v5P4Yf It's misleading.=