public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/101133] New: co_await doesn't accept a valid awaitable object if await_resume()'s return type is not a built-in type.
@ 2021-06-19  8:57 liuyaoxin1976 at qq dot com
  2021-09-23  7:19 ` [Bug c++/101133] [coroutines] " emil.kultje at ericsson dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: liuyaoxin1976 at qq dot com @ 2021-06-19  8:57 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101133

            Bug ID: 101133
           Summary: co_await doesn't accept a valid awaitable object if
                    await_resume()'s return type is not a built-in type.
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: liuyaoxin1976 at qq dot com
  Target Milestone: ---

#include <coroutine>
#include <string>

template<typename T>
struct Awaiter
{
    bool await_ready()                          const { return false; }    
    void await_suspend(std::coroutine_handle<>) const {}    
    T    await_resume()                         const { return T{}; }
};

struct ReturnObject
{
    struct promise_type
    {
        ReturnObject       get_return_object()        { return {}; }
        std::suspend_never initial_suspend() noexcept { return {}; }
        std::suspend_never final_suspend()   noexcept { return {}; }
        void               return_void()              {}
        void               unhandled_exception()      {}
    };
};

ReturnObject f()
{
    auto a1 = Awaiter<int>{};
    auto a2 = Awaiter<std::string>{};

    [[maybe_unused]] auto v1 = co_await a1; // ok
    [[maybe_unused]] auto v2 = co_await a2; // error
}

The error message is: no suspend point info for ''co_await' not supported by
dump_decl<declaration error>'

See also: https://godbolt.org/z/4xdYreb9f

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/101133] [coroutines] co_await doesn't accept a valid awaitable object if await_resume()'s return type is not a built-in type.
  2021-06-19  8:57 [Bug c++/101133] New: co_await doesn't accept a valid awaitable object if await_resume()'s return type is not a built-in type liuyaoxin1976 at qq dot com
@ 2021-09-23  7:19 ` emil.kultje at ericsson dot com
  2021-10-01 20:36 ` iains at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: emil.kultje at ericsson dot com @ 2021-09-23  7:19 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101133

emil.kultje at ericsson dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |emil.kultje at ericsson dot com

--- Comment #1 from emil.kultje at ericsson dot com ---
I'm also seeing this. It seems this was introduced in GCC 10.2. It worked fine
in GCC 10.1, but not in later version.

https://godbolt.org/z/eYjbnoxxK

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/101133] [coroutines] co_await doesn't accept a valid awaitable object if await_resume()'s return type is not a built-in type.
  2021-06-19  8:57 [Bug c++/101133] New: co_await doesn't accept a valid awaitable object if await_resume()'s return type is not a built-in type liuyaoxin1976 at qq dot com
  2021-09-23  7:19 ` [Bug c++/101133] [coroutines] " emil.kultje at ericsson dot com
@ 2021-10-01 20:36 ` iains at gcc dot gnu.org
  2021-10-02 18:39 ` iains at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: iains at gcc dot gnu.org @ 2021-10-01 20:36 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101133

Iain Sandoe <iains at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
           Assignee|unassigned at gcc dot gnu.org      |iains at gcc dot gnu.org
   Last reconfirmed|                            |2021-10-01
                 CC|                            |iains at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #2 from Iain Sandoe <iains at gcc dot gnu.org> ---
I have an initial fix for this.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/101133] [coroutines] co_await doesn't accept a valid awaitable object if await_resume()'s return type is not a built-in type.
  2021-06-19  8:57 [Bug c++/101133] New: co_await doesn't accept a valid awaitable object if await_resume()'s return type is not a built-in type liuyaoxin1976 at qq dot com
  2021-09-23  7:19 ` [Bug c++/101133] [coroutines] " emil.kultje at ericsson dot com
  2021-10-01 20:36 ` iains at gcc dot gnu.org
@ 2021-10-02 18:39 ` iains at gcc dot gnu.org
  2021-10-03 19:46 ` cvs-commit at gcc dot gnu.org
  2022-05-02 16:45 ` s_gccbugzilla at nedprod dot com
  4 siblings, 0 replies; 6+ messages in thread
From: iains at gcc dot gnu.org @ 2021-10-02 18:39 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101133

Iain Sandoe <iains at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/101133] [coroutines] co_await doesn't accept a valid awaitable object if await_resume()'s return type is not a built-in type.
  2021-06-19  8:57 [Bug c++/101133] New: co_await doesn't accept a valid awaitable object if await_resume()'s return type is not a built-in type liuyaoxin1976 at qq dot com
                   ` (2 preceding siblings ...)
  2021-10-02 18:39 ` iains at gcc dot gnu.org
@ 2021-10-03 19:46 ` cvs-commit at gcc dot gnu.org
  2022-05-02 16:45 ` s_gccbugzilla at nedprod dot com
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-10-03 19:46 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101133

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Iain D Sandoe <iains@gcc.gnu.org>:

https://gcc.gnu.org/g:1b54a7226368bf86361e5c9d8ae523193037a0ac

commit r12-4100-g1b54a7226368bf86361e5c9d8ae523193037a0ac
Author: Iain Sandoe <iain@sandoe.co.uk>
Date:   Sat Oct 2 13:40:09 2021 +0100

    coroutines: Ensure co_await_exprs have TREE_SIDE_EFFECTS set [PR 101133].

    Although it is not immediately evident from the symptoms, the PR is
    caused by a variable having a DECL_INITIAL() containing a co_await.
    This is not correct, since such expressions have side-effects.

    We were marking the overall co_await expression correctly, but if a
    consumer of that expression stripped out the underlying co_await_expr
    then the latter would not be properly marked.

    Fixed by marking both the underlying and any containing await expr
    with TREE_SIDE_EFFECTS.  Also mark type-dependent co_await expressions.

    Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>

            PR c++/101133

    gcc/cp/ChangeLog:

            * coroutines.cc (build_co_await): Mark co_await_expr trees
            with TREE_SIDE_EFFECTS, also mark any containing expression.
            (finish_co_await_expr): Mark type-dependent co_await_expr
            trees with TREE_SIDE_EFFECTS.

    gcc/testsuite/ChangeLog:

            * g++.dg/coroutines/pr101133.C: New test.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/101133] [coroutines] co_await doesn't accept a valid awaitable object if await_resume()'s return type is not a built-in type.
  2021-06-19  8:57 [Bug c++/101133] New: co_await doesn't accept a valid awaitable object if await_resume()'s return type is not a built-in type liuyaoxin1976 at qq dot com
                   ` (3 preceding siblings ...)
  2021-10-03 19:46 ` cvs-commit at gcc dot gnu.org
@ 2022-05-02 16:45 ` s_gccbugzilla at nedprod dot com
  4 siblings, 0 replies; 6+ messages in thread
From: s_gccbugzilla at nedprod dot com @ 2022-05-02 16:45 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101133

Niall Douglas <s_gccbugzilla at nedprod dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |s_gccbugzilla at nedprod dot com

--- Comment #4 from Niall Douglas <s_gccbugzilla at nedprod dot com> ---
Looks like this fix didn't get backported into the 11 branch, as the 11.3
release is also broken.

https://godbolt.org/z/ojo759Md1

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-05-02 16:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-19  8:57 [Bug c++/101133] New: co_await doesn't accept a valid awaitable object if await_resume()'s return type is not a built-in type liuyaoxin1976 at qq dot com
2021-09-23  7:19 ` [Bug c++/101133] [coroutines] " emil.kultje at ericsson dot com
2021-10-01 20:36 ` iains at gcc dot gnu.org
2021-10-02 18:39 ` iains at gcc dot gnu.org
2021-10-03 19:46 ` cvs-commit at gcc dot gnu.org
2022-05-02 16:45 ` s_gccbugzilla at nedprod dot com

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).