<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/105708>105708</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
-Wno-unused-comparison disables unused result warning even on comparison ops that are explicitly `[[nodiscard]]`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
pkasting
</td>
</tr>
</table>
<pre>
`-Wunused-comparison` warns about unused results of comparison ops like ==, even if they are not (implicitly or explicitly) `[[nodiscard]]`.
However, if that is disabled (but the general `-Wunused-result` is left enabled), it's impossible to opt-in specific cases by explicitly marking them `[[nodiscard]]`; no warning will be generated. IMO, this combination should produce an ordinary `-Wunused-result` diagnostic instance (no special detection or warning text relating to the fact that the function in question is a comparison op).
Live example: https://godbolt.org/z/dPY19dha3
Perhaps this is WAI, but I think it's surprising and has no user benefit over my proposed behavior.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8U01v4zYQ_TXUZWBDomzZOuiQNDAaoEX3FvQ4FEfWNBSpcign7q8vKG92nS26AGGL0ny99-ahCJ89Uaf2j2r_VOCSxhC7-RUlsT8XJthrp5py87L4Rchu-jDNGFmCV00Jbxi9AJqwJLgFQCRZXBIIA3yPhTALOH4lUPVTPvoXoAt54AHSSFfASOBDAqWPPM2Oe07uCiECvX_clG5BNeU66KMPlqXHaNX-KZ-m3KrySZUPt99fwxtdKOY2awdMwAKWBY0jm7uYJeXOcCZPER3cY7xByPhYwNGQgPyaqHS7lkxKHwR4moMIG0eQAoQ5bdiDzNTzwD30KCRgrncIYML4yv6cG08_w6LqR_BhZTeHv7FzYD5mTWS38Pz7H3mSNLJkmg17TBw8yBgWZ2GOwS49AXoI0bLHeP0fhJbx7IMk7oG9JPQ9ZXp8uCFBB5YS9WvxEL-NlOg9QSSHab2FlcsB-3Qje70t_pbGHv5eSG7PAvh5L5RuP0n3G18I6B2n2ZGqH2BMaRZVPyh9Uvp0DtYEl7YhnpU-_aP0yX75s2rtiPV9kS8UR5zlxg8LvDw8Z7qy6M_5pX_9EFGWOEeWjAK9hRElM78IRTDkaeAE4UIRpmsmdQ55xQ2NeOEQt4XtatvWLRbUVQe9q3dte2iLsWvaAUvaVYd93w5oKmMqamsyZPaHo2magjtd6l151Lo6lk113A41tcdDZfv2iIdG92pX0oTsts5dpgy3YJGFuqrcH8pj4dCQk9W1Wnt6g_Wr0jqbOHY5aWOWs6hd6ViSfC-TODnqNi8-bP5j6Q-HyGczf1N9tWzwPxp7lTw7-G7Vf7LdxRJd94OsnMbFbPswKX3Ko37928wx_EV9Uvq0AhSlT18ZuHT63wAAAP__pCKW1w">