[Bug c++/101367] [coroutines] destructor for capture in lambda temporary operand to co_yield expression called twice

2021-08-09 Thread noah at vectorized dot io via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101367

--- Comment #5 from Noah Watkins  ---
Got it. Thanks for clarifying, I must have misinterpreted your earlier comment.

On Mon, Aug 9, 2021 at 8:06 PM davidledger at live dot com.au
 wrote:
>
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101367
>
> --- Comment #4 from David Ledger  ---
> Yeah, I'm just saying I suspect the problem was still there with the empty
> capture list, its just not observable.
>
> --
> You are receiving this mail because:
> You reported the bug.

[Bug c++/101367] [coroutines] destructor for capture in lambda temporary operand to co_yield expression called twice

2021-08-08 Thread noah at vectorized dot io via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101367

--- Comment #3 from Noah Watkins  ---
Happy to work on providing a different reproducer if it is helpful.
This was the first smallish example we could create, and the `free of
an invalid pointer error` seemed as good enough as any unexpected
behavior for a similar situation.

On Sun, Aug 8, 2021 at 5:40 PM davidledger at live dot com.au
 wrote:
>
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101367
>
> David Ledger  changed:
>
>What|Removed |Added
> 
>  CC||davidledger at live dot 
> com.au
>
> --- Comment #2 from David Ledger  ---
> that may be expected, as std::string frees on destruction, where as an empty
> capture list doesn't.
>
> --
> You are receiving this mail because:
> You reported the bug.

[Bug c++/101367] [coroutines] destructor for capture in lambda temporary operand to co_yield expression called twice

2021-07-07 Thread noah at vectorized dot io via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101367

--- Comment #1 from Noah Watkins  ---
In the reproducer there are no errors for:

generator f() {
co_yield resource{[]{}};
}

but `free(): invalid pointer` occurs for:

generator f() {
std::string s;
co_yield resource{[s]{}};
}

[Bug c++/101367] New: [coroutines] destructor for capture in lambda temporary operand to co_yield expression called twice

2021-07-07 Thread noah at vectorized dot io via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101367

Bug ID: 101367
   Summary: [coroutines] destructor for capture in lambda
temporary operand to co_yield expression called twice
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: noah at vectorized dot io
  Target Milestone: ---

I'm observing an issue in which it appears that the destructor for a captured
object in a lambda which is passed as a temporary to a co_await/co_yield
expression is being called twice.

Here is a reproducer https://godbolt.org/z/8jrGx7qsT which is a slight
modification of the reproducer used in
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95599 that was related to the
order of destructors in co_await/co_yield expressions.

In the reproducer I gave when the lambda temporary doesn't capture a
std::string value things work, but when it does you can see that gcc reports
`free(): invalid pointer`.

It also appears that https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100611 may be
closely related.