public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/103358] New: what is the first constructor argument of lambda coroutine promise_type?
@ 2021-11-22 12:36 netcan1996 at gmail dot com
  2021-12-17 17:20 ` [Bug c++/103358] " iains at gcc dot gnu.org
  2021-12-18 13:04 ` netcan1996 at gmail dot com
  0 siblings, 2 replies; 3+ messages in thread
From: netcan1996 at gmail dot com @ 2021-11-22 12:36 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 103358
           Summary: what is the first constructor argument of lambda
                    coroutine promise_type?
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: netcan1996 at gmail dot com
  Target Milestone: ---

the C++20 standard(N4858) says:
> promise-constructor-arguments is determined as follows: overload resolution is performed on a promise
constructor call created by assembling an argument list with lvalues p1 . . .
pn. If a viable constructor is
found (12.4.3), then promise-constructor-arguments is (p1 , . . . , pn),
otherwise promise-constructor-
arguments is empty.

I tested gcc-12 coroutine feature, when I use the free coroutine function,
arguments are that function, but when I use lambda coroutine, the first
argument looks strange, the rest arguments are the same as lambda.

```cpp
auto test = [](int, char, double) -> task<void> {
    co_return;
};

```

the promise_type dumps all arguments type:
```cpp
        template<typename ...T>
        promise_type(T&&... args) {
            dump<T...> {};
        }
```

T = {const<lambda(int, char, double)>&&, int&, char&, double&} here, what is
the type `const<lambda(int, char, double)>&&`?

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

* [Bug c++/103358] what is the first constructor argument of lambda coroutine promise_type?
  2021-11-22 12:36 [Bug c++/103358] New: what is the first constructor argument of lambda coroutine promise_type? netcan1996 at gmail dot com
@ 2021-12-17 17:20 ` iains at gcc dot gnu.org
  2021-12-18 13:04 ` netcan1996 at gmail dot com
  1 sibling, 0 replies; 3+ messages in thread
From: iains at gcc dot gnu.org @ 2021-12-17 17:20 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |iains at gcc dot gnu.org

--- Comment #1 from Iain Sandoe <iains at gcc dot gnu.org> ---
There was a long discussion about this between the various WG21 paper authors.

The stated intend was that 'this' pointer and the 'lambda object pointer' were
intended to be cast to references (to the same type as their pointers).

This behaviour should be the same between MSVC, clang and GCC (but I fear that
the amendment did not make C++20 timescale - so we might need a coordinated
change to remove it from the compilers).

Does that explain what you are seeing?

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

* [Bug c++/103358] what is the first constructor argument of lambda coroutine promise_type?
  2021-11-22 12:36 [Bug c++/103358] New: what is the first constructor argument of lambda coroutine promise_type? netcan1996 at gmail dot com
  2021-12-17 17:20 ` [Bug c++/103358] " iains at gcc dot gnu.org
@ 2021-12-18 13:04 ` netcan1996 at gmail dot com
  1 sibling, 0 replies; 3+ messages in thread
From: netcan1996 at gmail dot com @ 2021-12-18 13:04 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Net Can <netcan1996 at gmail dot com> ---
(In reply to Iain Sandoe from comment #1)
> There was a long discussion about this between the various WG21 paper
> authors.
> 
> The stated intend was that 'this' pointer and the 'lambda object pointer'
> were intended to be cast to references (to the same type as their pointers).
> 
> This behaviour should be the same between MSVC, clang and GCC (but I fear
> that the amendment did not make C++20 timescale - so we might need a
> coordinated change to remove it from the compilers).
> 
> Does that explain what you are seeing?

yes, I see. thank you for your explanation.

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

end of thread, other threads:[~2021-12-18 13:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-22 12:36 [Bug c++/103358] New: what is the first constructor argument of lambda coroutine promise_type? netcan1996 at gmail dot com
2021-12-17 17:20 ` [Bug c++/103358] " iains at gcc dot gnu.org
2021-12-18 13:04 ` netcan1996 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).