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