Skip to content

No warning for comparison of integers of different signs #18878

Closed
@chengniansun

Description

@chengniansun
Bugzilla Link 18504
Version trunk
OS Linux
CC @zygoloid,@zhendongsu

Extended Description

Clang does not emit a warning for the comparison of integers of different signs.

I have the following program:

int unreported(unsigned a, int *b) {
        return a > (~(95 != *b));
}

And compile it with the following command, but Clang emits no warning for the expression "a > (~(95 != *b))"

$clang -Wall -Wextra -std=c11 -pedantic -c s.c
$clang --version
clang version 3.5 (trunk 198918)
Target: x86_64-unknown-linux-gnu
Thread model: posix

Differently, GCC emits a warning with the following command

gcc -Wall -Wextra -std=c11 -pedantic -c s.c

s.c: In function ‘unreported’:
s.c:7:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  return a > (~(95 != *b));
           ^

Metadata

Metadata

Assignees

Labels

awaiting-reviewHas pending Phabricator reviewclang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzergood first issuehttps://github.com/llvm/llvm-project/contribute

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions