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

            Bug ID: 108381
           Summary: GCC Static Analyzer evaluates ( ((c)<=(b)) &&
                    ((c)!=(b)) ) == false to be FALSE with the fact c >= b
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: analyzer
          Assignee: dmalcolm at gcc dot gnu.org
          Reporter: geoffreydgr at icloud dot com
  Target Milestone: ---

Hi, i found a problem that GCC Static Analyzer evaluates `( ((c)<=(b)) &&
((c)!=(b)) ) == false ` to be FALSE with the fact `c >= b`. However, CSA does
not have this problem.
GSA: https://godbolt.org/z/qjEvndsxT
CSA: https://godbolt.org/z/zMYheK7Pf

Compiler options: -O0 -fanalyzer

Input:
```c
#include "stdint.h"
#include <stdbool.h>


int a(int* b, int *c) {

d:
  if (c >= b) {

    __analyzer_eval((!(c >= b))==false);
    __analyzer_eval((((c)<=(b))&&((c)!=(b)))==false);
    __analyzer_eval(true);
    goto d;
  }
}
```


Output:
```bash
<source>: In function 'a':
<source>:10:5: warning: implicit declaration of function '__analyzer_eval'
[-Wimplicit-function-declaration]
   10 |     __analyzer_eval((!(c >= b))==false);
      |     ^~~~~~~~~~~~~~~
<source>:10:5: warning: TRUE
   10 |     __analyzer_eval((!(c >= b))==false);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:11:5: warning: FALSE
   11 |     __analyzer_eval((((c)<=(b))&&((c)!=(b)))==false);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:12:5: warning: TRUE
   12 |     __analyzer_eval(true);
      |     ^~~~~~~~~~~~~~~~~~~~~
<source>:11:5: warning: UNKNOWN
   11 |     __analyzer_eval((((c)<=(b))&&((c)!=(b)))==false);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:12:5: warning: TRUE
   12 |     __analyzer_eval(true);
      |     ^~~~~~~~~~~~~~~~~~~~~
Compiler returned: 0

```

Reply via email to