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: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected]
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.
_______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs