Issue 63301
Summary [clang-analyzer-deadcode.DeadStores] false positive for local constexpr c-string captured by lambda
Labels new issue
Assignees
Reporter R2RT
    Local `constexpr` c-string used only in lambda yields false positive about dead store.

Minimal repro: https://godbolt.org/z/qr8zGeGsv

```c++
int main() {
 constexpr auto constexprlocal = "c"; // warning: Value stored to 'constexprlocal' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
    auto callback = []() {
 return constexprlocal[0];
    };
    return callback();
}
```

More cases repro: https://godbolt.org/z/GqG8svY9o

```c++
#include <iostream>
constexpr auto constexprglobal = "a";
auto global = "a";

int main() {
    auto local = "b";
    constexpr auto constexprlocal = "c"; // warning: Value stored to 'constexprlocal' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
 constexpr auto constexprlocalint = 11;
    auto callback = [&]() {
 std::cout
            << constexprglobal
            << global
 << constexprlocal
            << local 
            << constexprlocalint
        ;
    };
    callback();
    return 0;
}
```


_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to