[clang] [analyzer] Fix false positive in strchr/strrchr with constant args (PR #210154)

Balázs Benics via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 23 07:25:04 PDT 2026


steakhal wrote:

There is a crash for this code:
```c++
  char *strchr(const char *, int);
  const unsigned short w[] = u"abc";
  void f(void){ (void)strchr((const char*)w, 'a'); }   // crash
```

While this is unusual code, the analyzer should gracefully handle the case without crashing.
The crash reproduces for strchr, strrchr, memchr, strstr, strpbrk (needle side too)

https://github.com/llvm/llvm-project/pull/210154


More information about the cfe-commits mailing list