Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing -Wreturn-stack-address cases for lambda. #102050

Open
hokein opened this issue Aug 5, 2024 · 1 comment
Open

Missing -Wreturn-stack-address cases for lambda. #102050

hokein opened this issue Aug 5, 2024 · 1 comment
Labels
clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer clang:memory-safety Issue/FR relating to the lifetime analysis in Clang (-Wdangling, -Wreturn-local-addr) false-negative lambda C++11 lambda expressions

Comments

@hokein
Copy link
Collaborator

hokein commented Aug 5, 2024

#include <algorithm>
#include <functional>

auto foo(int x) {
    return [&]() { return x + 1; }; // good, give a warning.
}
std::function<int()> foo2(int x) {
    return [&]() { return x + 1; }; // no warning
}

auto foo3(int x) {
    auto a = [&]() { return x + 1;};
    return a; // no warning.
}

https://godbolt.org/z/nfacaEfGM, it would be good to detect case 2 and case 3.

@hokein hokein added clang:frontend Language frontend issues, e.g. anything involving "Sema" clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer labels Aug 5, 2024
@llvmbot
Copy link
Member

llvmbot commented Aug 5, 2024

@llvm/issue-subscribers-clang-frontend

Author: Haojian Wu (hokein)

``` #include <algorithm> #include <functional>

auto foo(int x) {
return & { return x + 1; }; // good, give a warning.
}
std::function<int()> foo2(int x) {
return & { return x + 1; }; // no warning
}

auto foo3(int x) {
auto a = & { return x + 1;};
return a; // no warning.
}


https://godbolt.org/z/nfacaEfGM, it would be good to detect case 2 and case 3.
</details>

@EugeneZelenko EugeneZelenko added lambda C++11 lambda expressions false-negative and removed clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Aug 5, 2024
@hokein hokein added the clang:memory-safety Issue/FR relating to the lifetime analysis in Clang (-Wdangling, -Wreturn-local-addr) label Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer clang:memory-safety Issue/FR relating to the lifetime analysis in Clang (-Wdangling, -Wreturn-local-addr) false-negative lambda C++11 lambda expressions
Projects
None yet
Development

No branches or pull requests

3 participants