public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "marc.glisse at normalesup dot org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/43772] Errant -Wlogical-op warning when testing limits Date: Sat, 28 Apr 2012 18:50:00 -0000 [thread overview] Message-ID: <bug-43772-4-dGlx1bBAmG@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-43772-4@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43772 --- Comment #17 from Marc Glisse <marc.glisse at normalesup dot org> 2012-04-28 18:49:49 UTC --- (In reply to comment #16) > I understand now, and I think you are right. We don't have a warning for > "((int)x) < INT_MIN" or ((int)x) > INT_MAX but I think it should go to > Wtype-limits. Interestingly, for an int i, we don't warn for x<=INT_MAX, but we do warn for x<=(long)INT_MAX (adapt if your platform has int and long of the same size). > Do you think we could test this situation just before the Wlogical-op warning? It is easy to re-check inside warn_logical_operator if one of the tests is always true. I have no idea how to pass the information from Wtype-limits that warn_logical_operator shouldn't be called. > I can see that some macros may generate x >= INT_MIN but the x < INT_MIN case > seems less likely to be intented and we should warn (and then return and avoid > warning with Wlogical-op). I think < INT_MIN and >= INT_MIN should either both warn of both be quiet. It is a matter of style whether people write: if (x in range) do the work; or if (x out of range) abort; do the work; (In reply to comment #12) > Do you mean: > > if (or_op && integer_onep(tem)) { warn();} > else if (!or_op && integer_zerop(tem)) { warn();} Even smaller would be to replace the current (TREE_CODE (tem) != INTEGER_CST) with integer_zerop(tem) and pass build_range_check in_p^or_op (or in_p==or_op, don't know which) instead of just in_p. It would already be an improvement over the current situation, and I expect the remaining false positives to be very rare. i>=INT_MIN&&i<something or i<INT_MIN||i>something are common, but i<INT_MIN&&i>something seems less likely.
next prev parent reply other threads:[~2012-04-28 18:50 UTC|newest] Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <bug-43772-4@http.gcc.gnu.org/bugzilla/> 2011-06-15 19:20 ` eggert at gnu dot org 2011-07-15 3:02 ` eggert at gnu dot org 2012-04-28 12:20 ` marc.glisse at normalesup dot org 2012-04-28 12:33 ` manu at gcc dot gnu.org 2012-04-28 12:34 ` marc.glisse at normalesup dot org 2012-04-28 12:38 ` manu at gcc dot gnu.org 2012-04-28 12:40 ` marc.glisse at normalesup dot org 2012-04-28 12:50 ` manu at gcc dot gnu.org 2012-04-28 12:56 ` marc.glisse at normalesup dot org 2012-04-28 13:08 ` manu at gcc dot gnu.org 2012-04-28 18:50 ` marc.glisse at normalesup dot org [this message] 2012-04-28 21:53 ` eggert at gnu dot org 2012-04-28 22:17 ` marc.glisse at normalesup dot org 2012-04-28 22:41 ` eggert at gnu dot org 2012-05-05 11:32 ` manu at gcc dot gnu.org 2012-05-05 12:15 ` manu at gcc dot gnu.org 2014-06-10 23:19 ` P at draigBrady dot com 2010-04-16 21:44 [Bug c/43772] New: " P at draigBrady dot com 2010-04-17 11:03 ` [Bug c/43772] " rguenth at gcc dot gnu dot org 2010-04-17 17:41 ` P at draigBrady dot com 2010-04-22 0:38 ` P at draigBrady dot com 2010-09-23 6:52 ` muntyan at fastmail dot fm 2010-09-23 8:13 ` manu at gcc dot gnu dot org 2010-09-23 8:24 ` manu at gcc dot gnu dot 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-43772-4-dGlx1bBAmG@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: linkBe 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).