Issue 83835
Summary Clang doesn't warn about always false comparisons
Labels clang
Assignees
Reporter mushenoy
    Clang doesn't warn about always false comparisons. 
GCC reports the warning for the same program

Sample program:
```
#include <stddef.h>
#define getstr(s) ((const char *)((s) + 1))

int test(const char* s)
{
 if (s== NULL || getstr(s) == NULL)
 {
 return 1;
 }
 return 0;
}
```
Compilation with clang:
```
# clang -c -Wall program.c
#
```

Compilation with GCC:
```
# gcc -c -Wall program.c
program.c: In function test:
program.c:6:28: warning: the comparison will always evaluate as _false_ for the pointer operand in _s + 1_ must not be NULL [-Waddress]
 6 |  if (s== NULL || getstr(s) == NULL)
      |
```

Compiler versions:
```
clang version 16.0.6 
gcc (GCC) 13.2.1
```


_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to