<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/59616>59616</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            clang inconsistent warning on discarding 'nodiscard' result
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          wanghan02
      </td>
    </tr>
</table>

<pre>
    Reproducible code could be found below or on [godbolt](https://godbolt.org/z/c6rrnzoKz).

1. regular call: clang, gcc and VS all give warning on discarding 'nodiscard' result
2. inside noexcept operator: only VS gives warning on discarding 'nodiscard' result

I'm not sure if it is a clang (or standard?) policy to ignore warnings in unevaluated context. In my opinion consistent warning message is probably better.

```
[[nodiscard]] int bar(int n) noexcept {
 return n;
}

void foo() {
    if constexpr( noexcept(bar(1), 1) ) {} // warning only with VS inside noexcept operator
    [[maybe_unused]] auto n = (bar(1), 1); // warning with clang, gcc and VS
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyclE1r9DYQxz_N-DI8iz2O3w4-ZLssPPTWQq9Ftma9KlqN0UuSzacvijebNKRQCkaWZM_85uUvqRDM4phHaPbQHAqV4ln8-KzcclaupGISfR1_49WLTrOZLOMsOg_JapwYT5Jcnlh5RvEoDqHZL6InsRGaA1B_jnENUD8CHYGOt0878QvQ8RXoOLfeu1f59RVo2EF5gPJxG6sdel6SVR5nZS3Ujzhb5RagX3CZZ1RO4x-_o7IWF_PE-Ky8M27JMWgTZuV1XgF1Tm5roA49h2TjRqAdGheMZnTCLzOvEWVlr6L4TBNnr5mQvYf_4X4bfwJ1F3QSMSTPaE5oIpqAassGgXrxGKJyOvuoj0ADrmLNfMUoaBYn_p5cQOMwOX5SNqnIGmdxkV_iDn86vFxRVuOMuLwdTIjs4j3uC4egFs7o1cukJnvFiWNk_4-qQ1venm2ZdbH_SLE5QHNA4yJOygP1eeZyxPcKQrffTNFzTN6hg_q2A93hM-pJjMaTCFCfPXwYIuYy5Rwiv6wZc3cP1G_gCmjISqjeTG_m3QE3mX3qlr3is4nn3Mh_bfYdu6V7UdeJ_0wuBX7PWKUo6BDqTPgmBKj3X9Fv1G8U-7UW7wUv9FjroR5UwWPVdlVTD1R3xXnsaKaSqaFB6VN7Utz3VTlULc3tQ9WVfWFGKokqorIi6qpuN1RUKV0pXQ9tQz3DQ8kXZezO2qdLPnuFCSHx2Axt1RZWTWzD-xXgx_zTjyktAR5Ka0IMH2bRRMvjJlzjvlHZfzkdRfJ2_HItmHhO026WC9Ax026vH6uXv3iOQMe3iAPQ8S3ovwMAAP__azR8DA">