[Bug c++/90881] -Wunused-value false positive in SFINAE context
federico.kircheis at gmail dot com
gcc-bugzilla@gcc.gnu.org
Fri Jun 14 10:17:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90881
--- Comment #4 from Federico Kircheis <federico.kircheis at gmail dot com> ---
(In reply to Jonathan Wakely from comment #1)
> Confirmed. We shouldn't give that warning in unevaluated contexts (decltype,
> sizeof, etc.) because unevaluated operands have no effects at all, with or
> without the comma operator.
The compiler flag is about unused variables, not statements without effects.
I guess it would be nice for
----
int main(){
decltype(short(), int()) a = 1;
return a;
}
----
to have a warning that the left operand is unused (as of today), since here
SFINAE does not kick in:
--
<source>: In function 'int main()':
<source>:2:21: warning: left operand of comma operator has no effect
[-Wunused-value]
2 | decltype(short(), int()) a = 1;
| ^
--
But maybe there are not enough use-cases to be worth to diagnostic it.
More information about the Gcc-bugs
mailing list