Issue 123459
Summary False negatives clang-analyzer-core.StackAddressEscape when storing pointers/references in container
Labels new issue
Assignees
Reporter chrchr-github
    ~~~c++
#include <string>
#include <vector>

struct S { std::string* s; };
std::vector<S> f() {
 std::vector<S> v;
    {
        std::string a{ "abc" };
 v.push_back({ &a });
    }
    return v;
}

struct T { std::string& s; };
std::vector<T> g() {
    std::vector<T> v;
    {
        std::string b{ "def" };
        v.push_back({ b });
    }
    return v;
}

int main() {
    return f()[0].s->size() + g()[0].s.size();
}
~~~
https://godbolt.org/z/sMb8Ebv9j
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to