public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "hanwei62 at huawei dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/114763] Wduplicated-branches just check last else if-else case?
Date: Thu, 18 Apr 2024 08:32:15 +0000	[thread overview]
Message-ID: <bug-114763-4-7UFM2uWcE1@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-114763-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114763

--- Comment #3 from hanwei (K) <hanwei62 at huawei dot com> ---
(In reply to Andrew Pinski from comment #1)
> Note only the second case has if's 2 sides which are the same;
> it is basically `a ? b : (c ? d : d)`.
> 
> While the first case you have `a ? b : (c ? d : b)` which is not supposed to
> warn about at all because the 2 sides are not the same.
> 
> The reason is because that is how the grammar of C/C++ works.

So, Wduplicated-branches just check bottom two branches actually.
Because only the bottom two branches will same if we check followed the grammar
of C/C++.

  parent reply	other threads:[~2024-04-18  8:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-18  7:47 [Bug c/114763] New: " hanwei62 at huawei dot com
2024-04-18  8:16 ` [Bug c/114763] " pinskia at gcc dot gnu.org
2024-04-18  8:17 ` pinskia at gcc dot gnu.org
2024-04-18  8:31 ` hanwei62 at huawei dot com
2024-04-18  8:32 ` hanwei62 at huawei dot com [this message]
2024-04-18  8:45 ` jakub at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-114763-4-7UFM2uWcE1@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).