public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/95157] New: Missing -Wtautological-compare warning
@ 2020-05-15 22:13 simon.marchi at polymtl dot ca
  2020-05-16 16:40 ` [Bug c/95157] " harald at gigawatt dot nl
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: simon.marchi at polymtl dot ca @ 2020-05-15 22:13 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 95157
           Summary: Missing -Wtautological-compare warning
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: simon.marchi at polymtl dot ca
  Target Milestone: ---

Using this code:

volatile short insn;

int main()
{
  if (insn < 0 && insn > 3) {
      return 1;
  } else {
      return 0;
  }
}


clang 11 warns, but gcc doesn't:

$ gcc-10 test.c -c -Wall
$ g++-10 test.c -c -Wall
$ clang-11 test.c -c -Wall 
test.c:5:16: warning: overlapping comparisons always evaluate to false
[-Wtautological-overlap-compare]
  if (insn < 0 && insn > 3) {
      ~~~~~~~~~^~~~~~~~~~~
1 warning generated.
$ clang++-11 test.c -c -Wall
clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is
deprecated [-Wdeprecated]
test.c:5:16: warning: overlapping comparisons always evaluate to false
[-Wtautological-overlap-compare]
  if (insn < 0 && insn > 3) {
      ~~~~~~~~~^~~~~~~~~~~
1 warning generated.


I think -Wtautological-compare should trigger here.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-05-26 21:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-15 22:13 [Bug c/95157] New: Missing -Wtautological-compare warning simon.marchi at polymtl dot ca
2020-05-16 16:40 ` [Bug c/95157] " harald at gigawatt dot nl
2020-05-16 16:44 ` simon.marchi at polymtl dot ca
2020-05-26 21:26 ` mpolacek at gcc dot gnu.org

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).