public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "bazhenov.dn at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/96749] New: [coroutines] unexpected 'warning: statement has no effect [-Wunused-value]'
Date: Sun, 23 Aug 2020 05:57:37 +0000	[thread overview]
Message-ID: <bug-96749-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 96749
           Summary: [coroutines] unexpected 'warning: statement has no
                    effect [-Wunused-value]'
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bazhenov.dn at gmail dot com
  Target Milestone: ---

C++ compiler throws unexpected 'statement with no effect' warning at the ending
brace of a coroutine function when it utilizes co_await expression returning
non-void value which is used as an rvalue within operators '+=', '-=', '*=',
etc.

The warning doesn't appear if the co_await expression is used as an rvalue
within simple assignment ('=') to a temporary variable and then the latter used
within '+=' or other operation.

The attached test code is composed to reveal the issue but is not meant to do
any job. The "#if" alternative in the code can be used to show how warning
disappears.
In a case of meaningful code which causes the warning the code works as
expected.

- g++ version:
  g++ (GCC) 11.0.0 20200822 (experimental)
- configure pameters:
  configure --disable-multilib
- system:
  Linux beauty 5.4.0-42-generic #46-Ubuntu SMP Fri Jul 10 00:24:02 UTC 2020
x86_64 x86_64 x86_64 GNU/Linux
- compiler command:
  g++ -std=c++20 -O0 -g -Wall -fcoroutines -o test test.cpp

             reply	other threads:[~2020-08-23  5:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-23  5:57 bazhenov.dn at gmail dot com [this message]
2020-08-23  5:59 ` [Bug c++/96749] " bazhenov.dn at gmail dot com
2020-12-04 14:13 ` max at duempel dot org
2021-03-04 20:38 ` iains at gcc dot gnu.org
2021-03-12 15:36 ` iains at gcc dot gnu.org
2021-03-15 15:49 ` cvs-commit at gcc dot gnu.org
2021-03-22 22:04 ` cvs-commit at gcc dot gnu.org
2021-03-24 12:38 ` iains at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-96749-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).