<html>
<head>
<base href="https://bugs.llvm.org/">
</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 - [Coroutine] Invalidaded argument addresses"
href="https://bugs.llvm.org/show_bug.cgi?id=49854">49854</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[Coroutine] Invalidaded argument addresses
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Transformation Utilities
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>yedeng.yd@linux.alibaba.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Here is the reproducer: <a href="https://godbolt.org/z/nY4EqWz6P">https://godbolt.org/z/nY4EqWz6P</a>
The core code here are:
```
auto test() {
auto task2 = [this]() -> coro {
std::cout << "This in task2: " << this << "\n";
co_await suspend_always();
};
auto task1 = [this, task2] () -> coro {
std::cout << "This in task1: " << this << "\n";
auto c = task2();
co_await suspend_always();
c.handle.resume();
};
std::cout << "This in outside: " << this << "\n";
auto c = task1();
return c;
}
```
The value of `this` should be the same in test(), task1() and task2(). However,
the value printed in task2 is different with the value in test() and task1().
The corresponding IR is:
```
%class.anon = type { %class.foo* }
%class.anon.1 = type { %class.foo*, %class.anon }
define i8* @_ZN3foo4testEv(%class.foo* %0) {
%2 = alloca %class.anon.1, align 8
%10 = call i8* @_ZZN3foo4testEvENKUlvE0_clEv(%class.anon.1* nonnull %2)
}
define linkonce_odr dso_local i8* @_ZZN3foo4testEvENKUlvE0_clEv(%class.anon.1*
%0) {
store %0 to the Frame
}
define linkonce_odr dso_local i8* @_ZZN3foo4testEvENKUlvE0_clEv.resume(%
_ZZN3foo4testEvENKUlvE0_clEv.Frame* %0) {
Use %0 in the Frame. however, the address now is invalided.
}
```</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>