public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/114728] New: Coroutine called in short-circuit fold expression
@ 2024-04-15 21:05 yunus at ayar dot eu
  2024-04-15 21:07 ` [Bug c++/114728] " pinskia at gcc dot gnu.org
  2024-04-15 21:09 ` pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: yunus at ayar dot eu @ 2024-04-15 21:05 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 114728
           Summary: Coroutine called in short-circuit fold expression
           Product: gcc
           Version: 13.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: yunus at ayar dot eu
  Target Milestone: ---

Created attachment 57952
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57952&action=edit
Compressed version of a-test.ii

The following should print (and does with clang++ 17) only one `called` but it
prints it three times. Code (compiled with `g++ -std=c++20 test.cpp`):

```
#include <coroutine>
#include <iostream>

struct promise;

struct coroutine : std::coroutine_handle<promise> {
  using promise_type = ::promise;
  bool await_ready() { return true; }
  void await_suspend(std::coroutine_handle<> h) {}
  void await_resume() {}
};

struct promise {
  coroutine get_return_object() { return { coroutine::from_promise(*this) }; }
  std::suspend_never initial_suspend() noexcept { return {}; }
  std::suspend_always final_suspend() noexcept { return {}; }
  void return_void() {}
  void unhandled_exception() {}
};

inline coroutine test(auto)
{
  std::cout << "called\n";
  co_return;
}

inline coroutine do_one(auto... v)
{
  int i = 0;
  ((i++ == 1 && (co_await test(v), true)), ...);
}

int main() { do_one(1, 2, 3); }
```

I have also attached the compressed output of `g++ -save-temps`

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

* [Bug c++/114728] Coroutine called in short-circuit fold expression
  2024-04-15 21:05 [Bug c++/114728] New: Coroutine called in short-circuit fold expression yunus at ayar dot eu
@ 2024-04-15 21:07 ` pinskia at gcc dot gnu.org
  2024-04-15 21:09 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-04-15 21:07 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I think there is a dup of this bug somewhere ...

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

* [Bug c++/114728] Coroutine called in short-circuit fold expression
  2024-04-15 21:05 [Bug c++/114728] New: Coroutine called in short-circuit fold expression yunus at ayar dot eu
  2024-04-15 21:07 ` [Bug c++/114728] " pinskia at gcc dot gnu.org
@ 2024-04-15 21:09 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-04-15 21:09 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Depends on|                            |101027

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
PR 101027


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101027
[Bug 101027] Short-circuit behavior not respected with co_await in while head

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

end of thread, other threads:[~2024-04-15 21:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-15 21:05 [Bug c++/114728] New: Coroutine called in short-circuit fold expression yunus at ayar dot eu
2024-04-15 21:07 ` [Bug c++/114728] " pinskia at gcc dot gnu.org
2024-04-15 21:09 ` pinskia at gcc dot gnu.org

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