<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=http://email.email.llvm.org/c/eJylU9tu3CAQ_Rr8MtqVF-_FfvDDpqu0UV_7A2BmbVYYLMBJtl_fAW-aNI2iSpUAw4yZOefMIJ26tscADzBbhT5EYRXoyPgXYPvSo1BCaqPjddU5G-LKY5y9XcXrhOQHfNYhBogOOhG7gdaAAcJMWxFYeWLl8bbuy2V007RYcjwQM909O8d4zXgD7HC3eAGWTLDlrLrZ2OH0LtjbDA8RlKPkAnrnFFycBHdeYGnbQxwwIATnCW62E9DEUs4RtO2c99hFcwUCokeXsDwJbwM8DWjT5SRHhpxo6wDWRWI_Gd0tar1wro6f01bYmawerxP3lEgK_zd9qkTUHSwqaUsTWHV6K8dvifS_KmT_rA_R0lkDj6N7vIn0Ec-bOpB6I2ucjHqcvHtEeNMjKRaFJUVQgbzmcOi98zBiCKLHNXxDT9QPqUxG021FqVM90q86hBlhiHHKMvJ7Gr1T0pm4dr6n00-ah3rXfP_xdf-8LlRbqaZqREFKDs63l95NaIrZm_ZdFB2HWa47N9LBmMeXz4ooXIgZHXNyUuN-x-umLIZWdnyDFd8exEaIvdpsz43kO4lnVdVi250LIySa0LLdHePc4tOCn_Zsdyr-H4Fueck3G84Pm5qXZbXGvSxxz1WjVI2yrti2xFFos05xkkCFb3NIOfeBnCY9zVenCEH3FjEDJoRRR4Ptpy_8tdiv72OgJjCpbu_buMj42wz-F1FPXus>52890</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
readability-const-return-type does not correctly handle decltype(auto)
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
jgopel
</td>
</tr>
</table>
<pre>
As I understand it, `readability-const-return-type` exists to catch cases such as
```cpp
const auto foo() {
return 42;
}
```
It does a good job of catching these sorts of cases, but incorrectly (imo) warns when the `const` is not explicit, such as:
```cpp
decltype(auto) bar() {
static const int i = 42;
return i;
}
```
In cases such as this, removing the `const` is not correct and does not improve readability, as cited by the error message. Here's a live demo of the issue https://godbolt.org/z/7859KTG6x.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyNk8tu2zAQRb-G2gxs0JQlywstkhppg277A3xMJAY0KZBUEvfrO5ScJk2LoAAp8SHO3HuGUsFc-psE9zB7gzFl6Q3YzMQXYC2PKI1U1tl82ejgU95EzHP0m3yZkPYBX2zKCXIALbMe6ZkwQZppKBPjJ8Zvrs-Wr01P07qyxAM509mHEJjomDgCO9yuuwBrJtgLVl_X2OH0Idj7DPcZTKDkEoYQDDwGBeFhlWX9AHnEhJBCJLnLOgktLtWcwXodYkSd3QVIiD2HouVZRp_geURfDhcci-Ri2ybwIZP7yVm90nr1XN98btugdgs90RXvJZGS8W_7VIlsNayUrKcOrD69x_Ebkf1fQv7P-pAtuzCIeA5PV0j_8nmlA-VuLIzLoj1PMTwhvLsjJRaFJSJoQF2WcBhjiHDGlOSAW_iGkawfSpmcpdOGUpd6lE9tSjPCmPO0YBR31IZgVHB5G-JAs5_UD11z_P7ja_uyrUxfm2N9lFW22WH_6W19E_5W65EMuaLhY0mqObr-gxCbx1ltdTjTxLmn19eGKDxSOJou-gnoXSO6I6_GXjeNUbuu3TVCGLnnulVy10hVS73nXcsrJxW61LPmlgnh8XlFQGPWnCrbCy52OyEOu05wXm-xVRxbYY7GdKi6mu05nqV126KjEKpiv0hS85Bo05V_821TpmQHj7iko_jkdQyxfxzChK5aMveL8l8pxkil">