[Bug c++/123789] -Wunused-value false-positive for binary fold over comma
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Jan 23 13:48:51 GMT 2026
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123789
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #1)
> Can't you use pack indexing? void *ptr = sizeof...(ts) == 0 ? nullptr :
> ts...[sizeof...(ts)-1]; ?
No:
<source>:3:36: error: cannot index an empty pack
3 | void* ptr = sizeof...(ts) == 0 ? nullptr : ts...[sizeof...(ts)-1];
When the pack is empty, ts...[sizeof...(ts)-1] is ill-formed, and the third
operand isn't a discarded statement.
More information about the Gcc-bugs
mailing list