<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/149161>149161</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang-tidy complains on ignoring [[maybe_unused]] return values
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
alexolog
</td>
</tr>
</table>
<pre>
A `[[maybe_unused]]` attribute indicates the programmer's explicit intent to make the return value unimportant. For example, the return value of `printf` is almost universally ignored.
Code:
```
#include <cstdio>
struct Foo
{
[[maybe_unused]] int print() const { return std::printf("%d", i); }
int i{};
};
```
Warning:
```
<source>:5:5: warning: function 'print' should be marked [[nodiscard]] [modernize-use-nodiscard]
5 | [[maybe_unused]] int print() const { return std::printf("%d", i); }
| ^
| [[nodiscard]]
1 warning generated.
```
See [Compiler Explorer](https://godbolt.org/z/MEbaqsMzx).
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy8kzuzszYQhn_N0uzYA8LcCgp8ofuqFCkzAq2xcoREdHHs8-szsnHiJOe034wYCWYvz_uK5c7JSRO1UOyhOCY8-IuxLVd0M8pMyWDEve0QyvQRsJ_5faDfgg6OBBTHuMoUufdWDsETSi3kyD059BfCxZrJ8nkmC6xySLdFyVF6lNqT9ugNzvyDHqGWfLAar1wFwqDlvBjrufZb7I1FuvF5UQTs8P9gc454i5XanyOMdMjVbJyPZa5kHVfqjnLSxpLYQtpB2h2MIMjjKSp7rrQDlks9qiAIIT-MzgtpID89U5y3YfTYGxPfqz2kHSLid7ZEjfiAAlYDa3A02nmEav-id15EhLxb0WMYA1aIx3ZACayBfI9QHddesaSMrasj5PsHxuvwpuJXbrXU0xfy8oMzwY4UNeVdsT74598JeA569NJoBFat8BW6iwlK4EA4c_tBYtWsjZBu5PYlONpgBFktP2kTHG3-FfBUUCBUh5_nWWz2vKTTCoBv374UkXbZyxCcSJPlfv1r3pz8hSjmH8y8SEUWT7dFGUs2FmH1xfvFRUzWA-snIwaj_NbYCVj_Caz_cRr4H-7H5w1YEysnos1Fkzc8oTarClY2WZbWyaWt-VDxotidy-Kc1rwo87IpWcGq-lzznFeJbFnKirTKyqzOa1ZvWbk7Uz3wYkc5b2oBu5RmLtVWqescERLpXKA22zVZmSWKD6Tca_ZtG6M2Q5gc7FIlnXf_5HnpFbWj4nraeCnuOJp5UVxqh0Y_pyta9u3Vvo-sS4JV7X9skv4Shu1oZmB97Lpum8Wa32n0wPoHugPWr_TXlv0VAAD__35ncbo">