public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/110171] New: [[nodiscard]] of await_resume ignored when discarding result of co_await expression
@ 2023-06-08 13:21 lukaslang.bugtracker at outlook dot com
2024-07-16 15:08 ` [Bug c++/110171] " arsen at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: lukaslang.bugtracker at outlook dot com @ 2023-06-08 13:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110171
Bug ID: 110171
Summary: [[nodiscard]] of await_resume ignored when discarding
result of co_await expression
Product: gcc
Version: 11.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: lukaslang.bugtracker at outlook dot com
Target Milestone: ---
(Note: The example & bug is very similar to this here:
https://developercommunity.visualstudio.com/t/nodiscard-not-honored-by-co_await/1500944)
It seems that discarding the `co_await`ed result of an awaitable with
`[[nodiscard]]` `await_resume` doesn't lead to the expected warning
([Godbolt](https://godbolt.org/z/o47EdzMj8)):
```
#include <coroutine>
struct must_check_result
{
bool await_ready() { return false; }
void await_suspend(std::coroutine_handle<>) {}
[[nodiscard]] bool await_resume() { return {}; }
};
struct task {};
namespace std
{
template<typename... Args>
struct coroutine_traits<task, Args...>
{
struct promise_type
{
task get_return_object() { return {}; }
suspend_always initial_suspend() noexcept { return {}; }
suspend_always final_suspend() noexcept { return {}; }
void return_void() {}
void unhandled_exception() {}
};
};
}
task example()
{
co_await must_check_result(); // no warning even though await_ready is
marked [[nodiscard]]
must_check_result().await_resume();
}
```
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/110171] [[nodiscard]] of await_resume ignored when discarding result of co_await expression
2023-06-08 13:21 [Bug c++/110171] New: [[nodiscard]] of await_resume ignored when discarding result of co_await expression lukaslang.bugtracker at outlook dot com
@ 2024-07-16 15:08 ` arsen at gcc dot gnu.org
2024-07-22 12:17 ` arsen at gcc dot gnu.org
2024-07-25 20:12 ` arsen at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: arsen at gcc dot gnu.org @ 2024-07-16 15:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110171
Arsen Arsenović <arsen at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
Ever confirmed|0 |1
CC| |arsen at gcc dot gnu.org
Status|UNCONFIRMED |NEW
Last reconfirmed| |2024-07-16
--- Comment #1 from Arsen Arsenović <arsen at gcc dot gnu.org> ---
confirmed - likely because we explicitly discard the result in this case:
resume.4:;
<<cleanup_point <<< Unknown tree: expr_stmt
(void) must_check_result::await_resume (&Aw0) >>>>>;
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/110171] [[nodiscard]] of await_resume ignored when discarding result of co_await expression
2023-06-08 13:21 [Bug c++/110171] New: [[nodiscard]] of await_resume ignored when discarding result of co_await expression lukaslang.bugtracker at outlook dot com
2024-07-16 15:08 ` [Bug c++/110171] " arsen at gcc dot gnu.org
@ 2024-07-22 12:17 ` arsen at gcc dot gnu.org
2024-07-25 20:12 ` arsen at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: arsen at gcc dot gnu.org @ 2024-07-22 12:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110171
--- Comment #2 from Arsen Arsenović <arsen at gcc dot gnu.org> ---
no - it is because convert_to_void does not know how to warn about discarded
co_awaits, and it does not get re-invoked when we expand co_awaits
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/110171] [[nodiscard]] of await_resume ignored when discarding result of co_await expression
2023-06-08 13:21 [Bug c++/110171] New: [[nodiscard]] of await_resume ignored when discarding result of co_await expression lukaslang.bugtracker at outlook dot com
2024-07-16 15:08 ` [Bug c++/110171] " arsen at gcc dot gnu.org
2024-07-22 12:17 ` arsen at gcc dot gnu.org
@ 2024-07-25 20:12 ` arsen at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: arsen at gcc dot gnu.org @ 2024-07-25 20:12 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110171
Arsen Arsenović <arsen at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |arsen at gcc dot gnu.org
Status|NEW |ASSIGNED
--- Comment #3 from Arsen Arsenović <arsen at gcc dot gnu.org> ---
Fixed on trunk
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-07-25 20:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-08 13:21 [Bug c++/110171] New: [[nodiscard]] of await_resume ignored when discarding result of co_await expression lukaslang.bugtracker at outlook dot com
2024-07-16 15:08 ` [Bug c++/110171] " arsen at gcc dot gnu.org
2024-07-22 12:17 ` arsen at gcc dot gnu.org
2024-07-25 20:12 ` arsen at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).