public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/95519] New: [coroutines] non-functions for promise_type::return_void not supported
@ 2020-06-03 22:34 bruck.michael at gmail dot com
  2020-06-04 20:11 ` [Bug c++/95519] " iains at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: bruck.michael at gmail dot com @ 2020-06-03 22:34 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 95519
           Summary: [coroutines] non-functions for
                    promise_type::return_void not supported
           Product: gcc
           Version: 10.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bruck.michael at gmail dot com
  Target Milestone: ---

The standard only requires certain expressions e.g. "p.return_void()", not
specifically functions. return_void is the only one I tested, presumably this
applies to more.

The example uses a struct with operator() and a function pointer.
Both work on clang.

https://gcc.godbolt.org/z/oW8eQ3


#ifndef __clang__
#include <coroutine>
#else
#include <experimental/coroutine>
namespace std { using namespace experimental; }
#endif

#include <cstdio>

struct rv
{
    void operator ()(){
        printf("call to operator\n");
    }
};

struct pt
{
    using handle_t = std::coroutine_handle<pt>;
    auto get_return_object() noexcept { return handle_t::from_promise(*this); }

    std::suspend_never initial_suspend() const noexcept { return {}; }
    std::suspend_never final_suspend() const noexcept { return {}; }
    //void return_void() const noexcept { printf("call to function\n"); }

    // error 1
    rv return_void;
    // error 2
    //static constexpr auto return_void = []{ printf("call to lambda\n");};
    void unhandled_exception() const noexcept {}
};

template <> struct std::coroutine_traits<pt::handle_t>
    { using promise_type = pt; };

static pt::handle_t foo()
{ 
    co_return;
}

int main()
{
    foo();
}
---
<source>: In function 'pt::handle_t foo()':
<source>:38:5: error: call to non-function 'pt::return_void'
   38 |     co_return;
      |     ^~~~~~~~~
<source>:39:1: error: call to non-function 'pt::return_void'
   39 | }
      | ^

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

* [Bug c++/95519] [coroutines] non-functions for promise_type::return_void not supported
  2020-06-03 22:34 [Bug c++/95519] New: [coroutines] non-functions for promise_type::return_void not supported bruck.michael at gmail dot com
@ 2020-06-04 20:11 ` iains at gcc dot gnu.org
  2020-06-26 11:40 ` cvs-commit at gcc dot gnu.org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: iains at gcc dot gnu.org @ 2020-06-04 20:11 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
     Ever confirmed|0                           |1
           Assignee|unassigned at gcc dot gnu.org      |iains at gcc dot gnu.org
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2020-06-04
   Target Milestone|---                         |10.2

--- Comment #1 from Iain Sandoe <iains at gcc dot gnu.org> ---
thanks for the report.

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

* [Bug c++/95519] [coroutines] non-functions for promise_type::return_void not supported
  2020-06-03 22:34 [Bug c++/95519] New: [coroutines] non-functions for promise_type::return_void not supported bruck.michael at gmail dot com
  2020-06-04 20:11 ` [Bug c++/95519] " iains at gcc dot gnu.org
@ 2020-06-26 11:40 ` cvs-commit at gcc dot gnu.org
  2020-06-26 13:05 ` bruck.michael at gmail dot com
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-06-26 11:40 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 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:e74c76073092f4715007584edb1fe6b7a17274db

commit r11-1673-ge74c76073092f4715007584edb1fe6b7a17274db
Author: Iain Sandoe <iain@sandoe.co.uk>
Date:   Fri Jun 26 10:48:35 2020 +0100

    coroutines: Handle non-method promise expressions [PR95519]

    The PR  points out that the standard does not restrict promise
    expressions to methods, but the current implementation does.

    The patch factors out the building of a general promise expression,
    and then uses it in a fairly mechanical replacement of each case
    that we need such an expressions.

    This extends the handling for p.xxxxxx() expressions to cover the
    cases where the promise member is some form callable.

    Tests are added for each of the promise expressions.

    It's somewhat tortuous to find good uses for this for the
    get-return-object and get-return-object-on-allocation-failure
    cases, but they are included anyway.

    gcc/cp/ChangeLog:

            PR c++/95519
            * coroutines.cc (struct coroutine_info):Add a field
            to hold computed p.return_void expressions.
            (coro_build_promise_expression): New.
            (get_coroutine_return_void_expr): New.
            (finish_co_yield_expr): Build the promise expression
            using coro_build_promise_expression.
            (finish_co_return_stmt): Likewise.
            (build_init_or_final_await): Likewise.
            (morph_fn_to_coro): Likewise, for several cases.

    gcc/testsuite/ChangeLog:

            PR c++/95519
            * g++.dg/coroutines/torture/pr95519-00-return_void.C: New test.
            * g++.dg/coroutines/torture/pr95519-01-initial-suspend.C: New test.
            * g++.dg/coroutines/torture/pr95519-02-final_suspend.C: New test.
            * g++.dg/coroutines/torture/pr95519-03-return-value.C: New test.
            * g++.dg/coroutines/torture/pr95519-04-yield-value.C: New test.
            * g++.dg/coroutines/torture/pr95519-05-gro.C: New test.
            * g++.dg/coroutines/torture/pr95519-06-grooaf.C: New test.
            * g++.dg/coroutines/torture/pr95519-07-unhandled-exception.C: New
test.

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

* [Bug c++/95519] [coroutines] non-functions for promise_type::return_void not supported
  2020-06-03 22:34 [Bug c++/95519] New: [coroutines] non-functions for promise_type::return_void not supported bruck.michael at gmail dot com
  2020-06-04 20:11 ` [Bug c++/95519] " iains at gcc dot gnu.org
  2020-06-26 11:40 ` cvs-commit at gcc dot gnu.org
@ 2020-06-26 13:05 ` bruck.michael at gmail dot com
  2020-06-26 13:07 ` iains at gcc dot gnu.org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: bruck.michael at gmail dot com @ 2020-06-26 13:05 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Michael Bruck <bruck.michael at gmail dot com> ---
Some of the abort messages in main were not updated after copy/paste
"Failed to call one of the ... cases"

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

* [Bug c++/95519] [coroutines] non-functions for promise_type::return_void not supported
  2020-06-03 22:34 [Bug c++/95519] New: [coroutines] non-functions for promise_type::return_void not supported bruck.michael at gmail dot com
                   ` (2 preceding siblings ...)
  2020-06-26 13:05 ` bruck.michael at gmail dot com
@ 2020-06-26 13:07 ` iains at gcc dot gnu.org
  2020-06-26 13:18 ` iains at gcc dot gnu.org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: iains at gcc dot gnu.org @ 2020-06-26 13:07 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Iain Sandoe <iains at gcc dot gnu.org> ---
(In reply to Michael Bruck from comment #3)
> Some of the abort messages in main were not updated after copy/paste
> "Failed to call one of the ... cases"

I made individual test-cases for each promise entry, I'm not sure what's not
working?

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

* [Bug c++/95519] [coroutines] non-functions for promise_type::return_void not supported
  2020-06-03 22:34 [Bug c++/95519] New: [coroutines] non-functions for promise_type::return_void not supported bruck.michael at gmail dot com
                   ` (3 preceding siblings ...)
  2020-06-26 13:07 ` iains at gcc dot gnu.org
@ 2020-06-26 13:18 ` iains at gcc dot gnu.org
  2020-06-28 10:49 ` cvs-commit at gcc dot gnu.org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: iains at gcc dot gnu.org @ 2020-06-26 13:18 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Iain Sandoe <iains at gcc dot gnu.org> ---
(In reply to Iain Sandoe from comment #4)
> (In reply to Michael Bruck from comment #3)
> > Some of the abort messages in main were not updated after copy/paste
> > "Failed to call one of the ... cases"
> 
> I made individual test-cases for each promise entry, I'm not sure what's not
> working?

ah .. OK I see :)
I'll fix that up (but the test cases do not rely on those messages to function,
the abort() is what matters).

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

* [Bug c++/95519] [coroutines] non-functions for promise_type::return_void not supported
  2020-06-03 22:34 [Bug c++/95519] New: [coroutines] non-functions for promise_type::return_void not supported bruck.michael at gmail dot com
                   ` (4 preceding siblings ...)
  2020-06-26 13:18 ` iains at gcc dot gnu.org
@ 2020-06-28 10:49 ` cvs-commit at gcc dot gnu.org
  2020-06-29 11:49 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-06-28 10:49 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 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:31419a80b6bf84b1bf3bcb2489b2e660563f0dfe

commit r11-1692-g31419a80b6bf84b1bf3bcb2489b2e660563f0dfe
Author: Iain Sandoe <iain@sandoe.co.uk>
Date:   Sun Jun 28 10:10:06 2020 +0100

    coroutines, testsuite: Update log messages. [NFC, PR95519]

    This does not affect the test functionality, but only user-
    facing debug messages when the tests are run outside the
    test-suite.

    gcc/testsuite/ChangeLog:

            PR c++/95519
            * g++.dg/coroutines/torture/pr95519-02-final_suspend.C:
            Amend log messages.
            * g++.dg/coroutines/torture/pr95519-03-return-value.C:
            Likewise.
            * g++.dg/coroutines/torture/pr95519-04-yield-value.C:
            Likewise.
            * g++.dg/coroutines/torture/pr95519-05-gro.C: Likewise.

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

* [Bug c++/95519] [coroutines] non-functions for promise_type::return_void not supported
  2020-06-03 22:34 [Bug c++/95519] New: [coroutines] non-functions for promise_type::return_void not supported bruck.michael at gmail dot com
                   ` (5 preceding siblings ...)
  2020-06-28 10:49 ` cvs-commit at gcc dot gnu.org
@ 2020-06-29 11:49 ` cvs-commit at gcc dot gnu.org
  2020-06-30 12:49 ` iains at gcc dot gnu.org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-06-29 11:49 UTC (permalink / raw)
  To: gcc-bugs

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

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

https://gcc.gnu.org/g:6efc255f3bd347a6cd13737d8cf3540eb938f424

commit r10-8388-g6efc255f3bd347a6cd13737d8cf3540eb938f424
Author: Iain Sandoe <iain@sandoe.co.uk>
Date:   Mon Jun 29 11:22:15 2020 +0100

    coroutines: Handle non-method promise expressions [PR95519]

    The PR  points out that the standard does not restrict promise
    expressions to methods, but the current implementation does.

    The patch factors out the building of a general promise expression,
    and then uses it in a fairly mechanical replacement of each case
    that we need such an expressions.

    This extends the handling for p.xxxxxx() expressions to cover the
    cases where the promise member is some form callable.

    Tests are added for each of the promise expressions.

    It's somewhat tortuous to find good uses for this for the
    get-return-object and get-return-object-on-allocation-failure
    cases, but they are included anyway.

            Backported from e74c76073092f4715007584edb1fe6b7a17274db and
31419a80b6bf84b1bf3bcb2489b2e660563f0dfe

    gcc/cp/ChangeLog:

            PR c++/95519
            * coroutines.cc (struct coroutine_info):Add a field
            to hold computed p.return_void expressions.
            (coro_build_promise_expression): New.
            (get_coroutine_return_void_expr): New.
            (finish_co_yield_expr): Build the promise expression
            using coro_build_promise_expression.
            (finish_co_return_stmt): Likewise.
            (build_init_or_final_await): Likewise.
            (morph_fn_to_coro): Likewise, for several cases.

    gcc/testsuite/ChangeLog:

            PR c++/95519
            * g++.dg/coroutines/torture/pr95519-00-return_void.C: New test.
            * g++.dg/coroutines/torture/pr95519-01-initial-suspend.C: New test.
            * g++.dg/coroutines/torture/pr95519-02-final_suspend.C: New test.
            * g++.dg/coroutines/torture/pr95519-03-return-value.C: New test.
            * g++.dg/coroutines/torture/pr95519-04-yield-value.C: New test.
            * g++.dg/coroutines/torture/pr95519-05-gro.C: New test.
            * g++.dg/coroutines/torture/pr95519-06-grooaf.C: New test.
            * g++.dg/coroutines/torture/pr95519-07-unhandled-exception.C: New
test.

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

* [Bug c++/95519] [coroutines] non-functions for promise_type::return_void not supported
  2020-06-03 22:34 [Bug c++/95519] New: [coroutines] non-functions for promise_type::return_void not supported bruck.michael at gmail dot com
                   ` (6 preceding siblings ...)
  2020-06-29 11:49 ` cvs-commit at gcc dot gnu.org
@ 2020-06-30 12:49 ` iains at gcc dot gnu.org
  2020-10-31  2:45 ` hjl.tools at gmail dot com
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: iains at gcc dot gnu.org @ 2020-06-30 12:49 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #8 from Iain Sandoe <iains at gcc dot gnu.org> ---
fixed on master and 10.2

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

* [Bug c++/95519] [coroutines] non-functions for promise_type::return_void not supported
  2020-06-03 22:34 [Bug c++/95519] New: [coroutines] non-functions for promise_type::return_void not supported bruck.michael at gmail dot com
                   ` (7 preceding siblings ...)
  2020-06-30 12:49 ` iains at gcc dot gnu.org
@ 2020-10-31  2:45 ` hjl.tools at gmail dot com
  2020-10-31  7:53 ` iains at gcc dot gnu.org
  2020-10-31 12:39 ` hjl.tools at gmail dot com
  10 siblings, 0 replies; 12+ messages in thread
From: hjl.tools at gmail dot com @ 2020-10-31  2:45 UTC (permalink / raw)
  To: gcc-bugs

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

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
                 CC|                            |hjl.tools at gmail dot com,
                   |                            |skpgkp2 at gmail dot com
         Resolution|FIXED                       |---

--- Comment #9 from H.J. Lu <hjl.tools at gmail dot com> ---
On AVX or AVX512 machines, I got

FAIL: g++.dg/coroutines/torture/pr95519-05-gro.C   -O0  execution test
FAIL: g++.dg/coroutines/torture/pr95519-05-gro.C   -O1  execution test
FAIL: g++.dg/coroutines/torture/pr95519-05-gro.C   -O2  execution test
FAIL: g++.dg/coroutines/torture/pr95519-05-gro.C   -O3 -g  execution test
FAIL: g++.dg/coroutines/torture/pr95519-05-gro.C   -Os  execution test
FAIL: g++.dg/coroutines/torture/pr95519-05-gro.C   -O2 -flto
-fno-use-linker-plugin -flto-partition=none  execution test
FAIL: g++.dg/coroutines/torture/pr95519-05-gro.C   -O2 -flto
-fuse-linker-plugin -fno-fat-lto-objects  execution test

with r11-1673:

commit e74c76073092f4715007584edb1fe6b7a17274db
Author: Iain Sandoe <iain@sandoe.co.uk>
Date:   Fri Jun 26 10:48:35 2020 +0100

    coroutines: Handle non-method promise expressions [PR95519]

(gdb) r
Starting program: /tmp/x 

Program received signal SIGABRT, Aborted.
0x00007ffff7ad3b85 in raise () from /lib64/libc.so.6
(gdb) f 2
#2  0x00000000004013ee in main () at pr95519-05-gro.C:56
56            abort ();
(gdb) list
51         }
52        f.resume();
53        if (!f.done())
54          {
55            PRINT ("expected foo to be finished");
56            abort ();
57         }
58      
59        if (called_gro_op != 1)
60          {
(gdb)

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

* [Bug c++/95519] [coroutines] non-functions for promise_type::return_void not supported
  2020-06-03 22:34 [Bug c++/95519] New: [coroutines] non-functions for promise_type::return_void not supported bruck.michael at gmail dot com
                   ` (8 preceding siblings ...)
  2020-10-31  2:45 ` hjl.tools at gmail dot com
@ 2020-10-31  7:53 ` iains at gcc dot gnu.org
  2020-10-31 12:39 ` hjl.tools at gmail dot com
  10 siblings, 0 replies; 12+ messages in thread
From: iains at gcc dot gnu.org @ 2020-10-31  7:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from Iain Sandoe <iains at gcc dot gnu.org> ---
(In reply to H.J. Lu from comment #9)
> On AVX or AVX512 machines, I got

(I test on AVX and AVX512 machines without seeing this)

What version of glibc do you have?
this might be a dup of PR96504

(r11-1673 introduced the test, so it would not have failed before).

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

* [Bug c++/95519] [coroutines] non-functions for promise_type::return_void not supported
  2020-06-03 22:34 [Bug c++/95519] New: [coroutines] non-functions for promise_type::return_void not supported bruck.michael at gmail dot com
                   ` (9 preceding siblings ...)
  2020-10-31  7:53 ` iains at gcc dot gnu.org
@ 2020-10-31 12:39 ` hjl.tools at gmail dot com
  10 siblings, 0 replies; 12+ messages in thread
From: hjl.tools at gmail dot com @ 2020-10-31 12:39 UTC (permalink / raw)
  To: gcc-bugs

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

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|REOPENED                    |RESOLVED

--- Comment #11 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to Iain Sandoe from comment #10)
> (In reply to H.J. Lu from comment #9)
> > On AVX or AVX512 machines, I got
> 
> (I test on AVX and AVX512 machines without seeing this)
> 
> What version of glibc do you have?
> this might be a dup of PR96504
> 

Yes, it is the same.

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

end of thread, other threads:[~2020-10-31 12:39 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-03 22:34 [Bug c++/95519] New: [coroutines] non-functions for promise_type::return_void not supported bruck.michael at gmail dot com
2020-06-04 20:11 ` [Bug c++/95519] " iains at gcc dot gnu.org
2020-06-26 11:40 ` cvs-commit at gcc dot gnu.org
2020-06-26 13:05 ` bruck.michael at gmail dot com
2020-06-26 13:07 ` iains at gcc dot gnu.org
2020-06-26 13:18 ` iains at gcc dot gnu.org
2020-06-28 10:49 ` cvs-commit at gcc dot gnu.org
2020-06-29 11:49 ` cvs-commit at gcc dot gnu.org
2020-06-30 12:49 ` iains at gcc dot gnu.org
2020-10-31  2:45 ` hjl.tools at gmail dot com
2020-10-31  7:53 ` iains at gcc dot gnu.org
2020-10-31 12:39 ` hjl.tools 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).