https://bugs.llvm.org/show_bug.cgi?id=48522
Bug ID: 48522
Summary: Missing -Wreturn-local-addr warning with std::move
Product: clang
Version: unspecified
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: -New Bugs
Assignee: unassignedclangb...@nondot.org
Reporter: efrie...@quicinc.com
CC: aa...@aaronballman.com, htmldevelo...@gmail.com,
llvm-bugs@lists.llvm.org, ndesaulni...@google.com,
neeil...@live.com, richard-l...@metafoo.co.uk
Testcase:
#include <utility>
const int &byref() {
int x = 0;
return std::move(x);
}
This is returning the address of a local variable, but clang doesn't detect it.
gcc does detect this.
There are a couple ways we could address this:
1. Special-case calls to the symbol std::move.
2. Analyze the loop body of inline functions for a return statement that
returns a reference argument/pointer (sort of like the LLVM IR "returned"
attribute).
The static analyzer's core.StackAddressEscape analysis does correctly warn.
Not sure how far we want to go in the compiler, but this particular case seems
low-cost/high-impact.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs