<html>
<head>
<base href="https://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - False positive with -Wreturn-stack-address and rvalue references"
href="https://llvm.org/bugs/show_bug.cgi?id=25356">25356</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>False positive with -Wreturn-stack-address and rvalue references
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C++11
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>cameronwhite91@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>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;
}</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>