track constraints between symbolics
| Bugzilla Link | 2834 |
| Version | unspecified |
| OS | Linux |
| Reporter | LLVM Bugzilla Contributor |
| CC | @tkremenek |
Extended Description
I get a null pointer dereference warning when I try to analyze following code:
void do_stupid_things(char* a, char* b)
{
if (a != b) {
if (a != NULL || b == NULL) {
a[0] = '\0';
}
}
}
It should be the same as
void do_stupid_things(char* a, char* b)
{
if (a != NULL && b == NULL) {
a[0] = '\0';
}
}
Which will not produce any warnings
Excellent test case. The issue has to do with not tracking symbolic relationships between 'a' and 'b'; this is something that we need to do, but I probably won't be able to get to it in the immediate short term.
assigned to @tkremenek
Bisected: the tested witness changes behavior starting with https://github.com/llvm/llvm-project/commit/e63b488f2755f91e8147fd678ed525cf6ba007cc.
This comparison analyzes the supplied C example with --analyze -DNULL=0.
Godbolt: https://godbolt.org/z/rdzjhnnY4
- Clang 11.0.1: Reports a null pointer dereference at
a[0] - Clang 12.0.0: No longer reports the null pointer dereference at
a[0] - Clang (trunk): Produces no null pointer dereference warning
This is only an observed change in behavior. I have not checked whether this commit addresses the cause of this report or only stops it from reproducing; whether that resolves the issue is up to the maintainers.
Prepared with assistance from Codex.
Fixed by e63b488f2755f91e8147fd678ed525cf6ba007cc in clang-12