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

    <tr>
        <th>Summary</th>
        <td>
            Unnecessary -Wunused-value warning for fold expression with empty pack
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    The fold expression in the following program produces the warning `expression result unused [-Wunused-value]` (https://godbolt.org/z/715deezdG) in clang 5.0.0 and up (verified on 20.0.1):
```
#include <iostream>
#include <sstream>

template <class... Args>
std::string concat(Args &&...args) {
  std::ostringstream out;
 (out << ... << args);
  return out.str();
}

int main() {
    std::cout << concat();
}
```
I assume the reason is that when no arguments are passed to the function, the fold expression reduces to the expression `(out)`. If we had used the syntax `(out)` alone, the warning would be valid. But this code is meaningful when passing arguments to the function, and it would be useful to allow no arguments without warnings.
Workaround: `std::ignore = (out << ... << args)`.
Similar: https://github.com/llvm/llvm-project/issues/45124

</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJycVMuO4zYQ_Jr2pbECTb3sgw6emTjYcxLsmRLbMrMUKfBh7-zXBy15PJ7ZAAECGJDg6q6uapaoYjSjI-qgfoL6ZaNyOvvQxQu5qJzuKYyb3uvX7s8z4clbjfRjDhSj8Q6Nw7T-bf3VuBHn4MegJn7qPFBc4KsKjkFoxENvoJhtwuxyJI1QP335tr5_uSibCeoXaASC3J1TmiOUB5BHkMfR697bVPgwgjz-BHlst7Um-ql_B7lnRYNVbsS6EIVA5TTmmVkuFMzJkEbvUIpCFFuQe2YVB2jE7ScOIEvjBps1IZTPxscUSE1Q_vYLFj9A4pBomq1KCzZYFWNRFHgIY1wrYtI8rTzEFHgZg3eDSiB3XIIgG5BNURSKG-QeoX0CcUC8t_m1bx2KPicolwqQO58TD4XyGXnm7fXGdCvDQCkHx41FTAHk7o5B-7I6MC7hpIxbwbuEBxHDw6i7gc9ED9v8iirGPNESg0AqcmY4FCrh9UwOnWedeSKXIqpAOKvIcUh-DVZ2QzLegXx-C9qH_AW6pWwtf0B4_rIZVteIAr-e8Ep4VhqXvHF5fHVJ_fhcisp6R28T37J79dlq7Akvyhpd4FNOmM4m4uA1saeJFBeesl2dsRFufLf3L544nia9k-dITJA8Kv6iPq7natKZ93-TFAsQh28-fFfBZ8cHxE7uR2VG5wOH8eW_I9II5vrDTMaqwESfPjmTzrkvBj-BPFp7eXt8mYP_m4YE8mhizBRBHqt6KysQh43uSr0v92pD3bat2rLdb_fV5tzJndbDoPu93O2Fqkql276ivt62p3LQ23JjOilkLeptI1rRlFVR9g2JhkidmlNbVyVUgiZlbMEa-B7YLNO7bSWkqDdW9WTjcp1J6eiKCwpS8u0WukV4n8cIlbAmpvhOk0yy1P3lHA0Uowqv-PFKuofh5MMvUeTTQZrm9IqzGr5vcrDd_1_jzculk_8EAAD__8dxyz4">