https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123789
Bug ID: 123789
Summary: -Wunused-value false-positive for binary foold over
comma
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: tkaminsk at gcc dot gnu.org
Target Milestone: ---
Currently for the following code:
```
template<typename... Ts>
void foo(Ts*... ts) {
void* ptr = (nullptr, ..., ts);
}
```
GCC raises a ` -Wunused-value` warning, when calling foo(&a)
(https://godbolt.org/z/GParoes5x):
```
<source>: In instantiation of 'void foo(Ts* ...) [with Ts = {int}]':
<source>:8:8: required from here
<source>:3:32: warning: left operand of comma operator has no effect
[-Wunused-value]
3 | void* ptr = (nullptr, ..., ts);
| ~~~~~~~~~~~~~~~^~~
```
As the above is only of use for binary fold over coma I can think of - to
provide value if pack is empty - this warning is false-positive.