-
Notifications
You must be signed in to change notification settings - Fork 11.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
clang incorrectly warns about returning reference to local #112021
Comments
@llvm/issue-subscribers-coroutines Author: None (kelbon)
pipeline ref with warn:
https:/kelbon/kelcoro/actions/runs/11295888979/job/31419583993?pr=31 warning:
code: dd::task<int&> rvo_task_ref(int& x) {
(void)co_await jump_on(TP);
int*& ret = co_await dd::this_coro::return_place;
ret = &x;
co_return dd::rvo;
}
TEST(rvo_tasks) {
int x = 0;
error_if(&rvo_task_ref(x).get() != &x);
return error_count;
} Description of what happens: task stores int* in its promise, local variable in TEST goes into coroutine by reference (and reference stored on coroutine frame) Compiler for some reasons thinks, that reference to 'x' is dangling, seems for me, that its incorrect |
Are you able to produce a self-contained example of this issue? |
CC @ChuanqiXu9 |
feel free to git clone project and ctest it, may be minimized by removing all what not task, just im tired to do it |
pipeline ref with warn:
https:/kelbon/kelcoro/actions/runs/11295888979/job/31419583993?pr=31
warning:
code:
Description of what happens:
task stores int* in its promise, local variable in TEST goes into coroutine by reference (and reference stored on coroutine frame)
Then, .get creates another coroutine and does get (blocking wait for result), returns int&.
Compiler for some reasons thinks, that reference to 'x' is dangling, seems for me, that its incorrect
The text was updated successfully, but these errors were encountered: