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

    <tr>
        <th>Summary</th>
        <td>
            `misc-const-correctness` false positive if variable is reassigned in `constexpr` branch of templated method
        </td>
    </tr>

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

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

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

<pre>
    `misc-const-correctness` incorrectly wants to make `a` `const` in clang-tidy 15 for the following code (https://godbolt.org/z/qjKMz3PnP)
```
template <typename T>
void test(){
    int a = 0;
    if constexpr (false) {
        a = 1;
    }
}

int main() {
    test<int>();
}
```

Removing the templating from the function makes clang-tidy work correctly.
Removing the `constexpr` makes it also work.


</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx9Uttu2zAM_Rr5RYjhyPcHP7TN9jIMKIb9gGzTtlpZ8iQ5Wfr1o-SkTYpigm4UycMjkq3uzw0pklnYbtdpZR3uxkDnFFiLCirU5UGe6YkrZ6nTdOavQFHLvQWu4LlZ005yNe6c6M90n9NBG-omwFNKfRJqpJ3u0ZdVk3OLJekDYd9xjrpvtXSxNiNKb7j-vPz4-ZY-q2fCapIcSPKAAS4ziA7mRXKHYOmTOy-g-Az0N0m_beqjFj11gLxY5SHKx-2d4hDKUY5-B5qQ9PZ9oOEr8HcxnuPApQV0pnfefmze-ztvUh4uRN8vYffRZi7URuQeKxBMn9DEE9-YXjE_YO4_vu2_YNZHn1Cf3ksuvDgYPW8pX1XnhFahWva2LidtXul7WeMv8K419Ynwdd0gBGZNWh3841suETT7oiizghVFHfVN2tdpzSMnnIT_t1fIMF20FU4cwRfgyI3grcS7pQa4tWJU0PvO-kyqNVx1E9XD9ftoNoObdB-tRjafGky4aW3jTs8oSHm8HrvF6BckhKKwdgWLl7wqyyqamrIbIGVD12asaKsuy_MiKSpohyxLCjZkkeQtSNuQ_JEwpuBEAwTeSX6IRMMSxvb7JE2qJGN1zCHlXd1DX2R1XtUJyRLAvpCx5-E7PzJNoNSuo0WlFNbZD-UlFRDCIT5f8aumaXvOLUQhchOY_wMqLCx5">