<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/70323>70323</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-tidy] incorrect `misc-const-correctness` warning emitted for C++17 fold expression
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-tidy
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
romintomasetti
</td>
</tr>
</table>
<pre>
The following snippet can be used to "concatenate" a series of variadic parameters, thanks to a fold expression.
`clang-tidy` emits `misc-const-correctness` for the line declaring `oss`. I think it should not.
Command to run the example:
> clang-tidy --checks=misc-const-correctness --extra-arg=-std=c++20 test.cpp
```c++
#include <concepts>
#include <sstream>
#include <string>
//! Concatenate arguments in a @c std::string using a @c std::ostringstream.
template <typename... Args> requires (sizeof...(Args) > 0)
std::string concatenate(Args&&... args)
{
std::ostringstream oss;
(oss << ... << std::forward<Args>(args));
return oss.str();
}
```
I'm using `Ubuntu LLVM version 17.0.4` version of `clang-tidy`.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8VE2P4zYM_TXMhbDhSI5jH3yYSXaABba3tndFZmJ1bMkV6fnory_keDqZYLeAIBsi-fgeJdIwu4snamH3CLvjxszSh9jGMDovYTRMIm5zCt17-3tPeA7DEF6dvyB7N00kaI3HE-HM1KEEBKVs8NYIeSMESqFBpuiIMZzxxURnOmdxMtGMJBQZ1AGlN_6ZU7hJGTqktykSsws-h-IIxcO6V4UdjL9k4rp3qAqk0QkjVMXo2GY2eJbMhhjJiifm5HIOEaUnHJwn7MgOJib6UBVhccjxO0rv_DM6Qe7DPHTog3zJewjjaPyiL85-gaM3M04Dgf6gpr_hJzfMMtuTfWbQx59TwyyjN4kmM_EC-pixdKCPFtQjqEdVoBBLbqfpTv51rW7rqdLO22HuCEEfUvFpEgb97WdmZolkxl9ZJdXm07i6PC1ri4fPi0UTL_NIXhidR4NQFhYXDQ-gH644OHPa743har0SWcssNE5DggV9kPeJvBkpz3N8iJekBCP9PbtIjKBqdv9QOOd5Dqpe7KrB5FOAaq5o9zy-PMg1pgJVpQzmirBK3a81RcRfEMb0avSNG6g6MCfioA-YINff_-LPIb6a2IE-rHJA1R9pVfMFLJLM0accOUsEVd86wP549w5ur-k7qP24lhyq4o_T7GXGHz_-_A1fKKZWwu0-L_IyNcXHSTjjfU_lm67VXaMbs6F2WzW1Vrqqik3f7hpVVzvdVCcq91RUO6WbrS73XdWcz7uy3LhWFUpvC1VtlS5Vkdd1t212Zl_bStd2V0JZ0GjckA_Dy5iHeNk45pnafaGV3gzmRAMvg0ipG05KpcEU2xSUneYLQ1kMjoU_YcTJsIywm7DdEZ1fO-7_R8SriT6VLU0ToW4ZGYdri2339wNpM8eh7UUmTre79MbFST-fchtGUE-J0_rJphj-IiugnhadDOppkfpvAAAA___yPK3x">