https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121691
Harald van Dijk <harald at gigawatt dot nl> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |harald at gigawatt dot nl
--- Comment #3 from Harald van Dijk <harald at gigawatt dot nl> ---
(In reply to Alejandro Colomar from comment #2)
> It's a bit difficult to compare. There's virtually no documentation for it.
> :)
Yeah, the documentation is lacking. The change that added it had a useful but
not 100% accurate description: https://reviews.llvm.org/D3976:
> -Wcomma emits a warning when there is a questionable use of the comma
> operator. It does this by only allowing certain expressions on the LHS of the
> comma operator, with all other expressions giving a warning. The current
> whitelisted expressions are increments, decrements, assignments, compound
> assignments, overloaded versions of these operators, and void returning
> functions.
So clang -Wcomma warns for all three of the examples, which I personally think
is more useful behaviour. The suggested way to suppress the warning is not
adding more parentheses, but casting the LHS to void (which is not mentioned as
being in the allowlist, but is allowed nonetheless). This also achieves the
intended objective of preventing accidentally becoming function arguments,
because function arguments cannot have void type.