public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/97561] New: coroutine_handle doesn't have inheritance
@ 2020-10-24 14:29 stinkingmadgod at gmail dot com
  2020-10-26 12:31 ` [Bug libstdc++/97561] " redi at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: stinkingmadgod at gmail dot com @ 2020-10-24 14:29 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 97561
           Summary: coroutine_handle doesn't have inheritance
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: stinkingmadgod at gmail dot com
  Target Milestone: ---

std::coroutine_handle<promise_type> doesn't inherit from
std::coroutine_handle<void>.

[coroutine.handle.general]
template<class Promise>
struct coroutine_handle : coroutine_handle<>

#include<coroutine>
struct task {
    struct promise_type {
        task get_return_object() { return {}; }
        std::suspend_never initial_suspend() { return {}; }
        std::suspend_never final_suspend() { return {}; }
        void return_void() {}
        void unhandled_exception() {}
    };
};

int main()
{
    std::coroutine_handle<task::promise_type> c;
    std::coroutine_handle<>& c2 = c;  // fails
}

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

* [Bug libstdc++/97561] coroutine_handle doesn't have inheritance
  2020-10-24 14:29 [Bug libstdc++/97561] New: coroutine_handle doesn't have inheritance stinkingmadgod at gmail dot com
@ 2020-10-26 12:31 ` redi at gcc dot gnu.org
  2020-10-26 12:33 ` redi at gcc dot gnu.org
  2020-10-26 17:15 ` stinkingmadgod at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2020-10-26 12:31 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This is intentional, see https://wg21.link/lwg3460 which is expected to be
voted into the draft in a few weeks. The inheritance requires unimplementable
and nonsensical behaviour.

You can still do this:

    std::coroutine_handle<task::promise_type> c;
    std::coroutine_handle<> c2 = c;

You just can't bind a coroutine_handle<> reference to a coroutine_handle<P>
directly.

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

* [Bug libstdc++/97561] coroutine_handle doesn't have inheritance
  2020-10-24 14:29 [Bug libstdc++/97561] New: coroutine_handle doesn't have inheritance stinkingmadgod at gmail dot com
  2020-10-26 12:31 ` [Bug libstdc++/97561] " redi at gcc dot gnu.org
@ 2020-10-26 12:33 ` redi at gcc dot gnu.org
  2020-10-26 17:15 ` stinkingmadgod at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2020-10-26 12:33 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Do you have a real world use case where the inheritance is actually required?

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

* [Bug libstdc++/97561] coroutine_handle doesn't have inheritance
  2020-10-24 14:29 [Bug libstdc++/97561] New: coroutine_handle doesn't have inheritance stinkingmadgod at gmail dot com
  2020-10-26 12:31 ` [Bug libstdc++/97561] " redi at gcc dot gnu.org
  2020-10-26 12:33 ` redi at gcc dot gnu.org
@ 2020-10-26 17:15 ` stinkingmadgod at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: stinkingmadgod at gmail dot com @ 2020-10-26 17:15 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from stinkingmadgod at gmail dot com ---
Thanks for the link.

I was attempting to create a type-erased task type where the handles in one
case was be passed in as a std::coroutine_handle<>& to avoid using
std::function and the like. It was experimental and unlikely to be motivating,
but I initially thought the inheritance situation was a bug.

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

end of thread, other threads:[~2020-10-26 17:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-24 14:29 [Bug libstdc++/97561] New: coroutine_handle doesn't have inheritance stinkingmadgod at gmail dot com
2020-10-26 12:31 ` [Bug libstdc++/97561] " redi at gcc dot gnu.org
2020-10-26 12:33 ` redi at gcc dot gnu.org
2020-10-26 17:15 ` stinkingmadgod at gmail 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).