<html>
<head>
<base href="http://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 --- - wrong lifetime for function parameters"
href="http://llvm.org/bugs/show_bug.cgi?id=17860">17860</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>wrong lifetime for function parameters
</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++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>richard-llvm@metafoo.co.uk
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>The destructor for a function parameter is called at the wrong time. We delay
until the end of the full-expression containing the call, but the parameter's
lifetime is supposed to end when the function returns. For instance:
#include <stdio.h>
struct X {
const char *p;
~X() { puts(p); }
};
void f(X, X) {}
int main() {
f({"1"}, X{"3"}), X{"2"};
}
is required to print:
1
2
3
but clang (and edg and g++) print:
2
3
1
and MSVC will presumably print:
1
3
2
(Note that braced initialization of the parameter does not create a temporary.
The same effect can be seen by passing a local variable of type X to the
function.)
If we get this right, we can reduce stack usage in some cases, so it's worth
investigating whether real code will be broken by this.</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>