[llvm-bugs] [Bug 25356] New: False positive with -Wreturn-stack-address and rvalue references
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Oct 30 08:28:53 PDT 2015
https://llvm.org/bugs/show_bug.cgi?id=25356
Bug ID: 25356
Summary: False positive with -Wreturn-stack-address and rvalue
references
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++11
Assignee: unassignedclangbugs at nondot.org
Reporter: cameronwhite91 at gmail.com
CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
Classification: Unclassified
The attached code snippet produces the warning below, which I believe is
incorrect. If the typedef of T is changed to just "int", no error is produced.
------------
test.cc:12:12: warning: returning address of local temporary object
[-Wreturn-stack-address]
return x;
^
test.cc:11:12: note: binding reference variable 'x' here
auto &&x = foo();
^ ~~~~~
------------
typedef int * T;
T foo()
{
T x = 0;
return x;
}
T bar()
{
auto &&x = foo();
return x;
}
int main(void)
{
T x = bar();
return 0;
}
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20151030/5f384ff5/attachment.html>
More information about the llvm-bugs
mailing list