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

    <tr>
        <th>Summary</th>
        <td>
            [clang-tidy] clang-analyzer-core.uninitialized.Branch false positive
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          chrchr-github
      </td>
    </tr>
</table>

<pre>
    ~~~c++
#include <iostream>

void f(int N) {
        char* p = new char[N] { 1 };
        for (int i = 0; i < N; i++) 
                if (p[i]) {
                        //std::cout << 1 << ' '; // clean
                }
        delete [] p;
}

int main() {
        f(5);
}
~~~
~~~
[<source>:6:7: warning: Branch condition evaluates to a garbage value [clang-analyzer-core.uninitialized.Branch]
 if (p[i]) {
                    ^
~~~
The warning only appears for certain code in the `if` branch.
https://godbolt.org/z/c676jv3f7
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMU8GO6joM_Rp3Y4FCQtvpogsYhuWs3g-4SdpmFJIqSRkxC779KQUeetyrq4tC6iY-x8d2TTGawWndQrmH8lDQnEYfWjkGOYbVYNI4d0Xn1aW9Xq8S-D4vdgC2Ay6Mk3ZWGkG8Gx9T0HQC8XG_XvazNwp74G_GJfwE3iDUDzxr5EgB-A4nBHFAp79xOSn3n1AesiduEOoDiCek9wHvdGZBMRD7xXzHz8W8a8yhHiBgjekzbIJyb6A8vAq5L34EfoxJgdiB2Ek_p8ybqTcPA3id_znSzR2l1eT-x1Qf_ntV2uqk8VZcnJ6ZPH3yntM5kXHA316l5eKVwJtfodfr9cXIYcR79HOQOjdC7CoQuxrEDr8pOOOGbO4DOTmi9E6ZZLxDfSY7U9IRk0fCgUJHg8Z8ukiXltywIkf28qPDSvqg17MzziRD1vxotb5R5sIuOvAP1cbf_KD8eMnkn1E_JKN39oI0TZpCxNx_qUMi41B6pdE4TKNGqJjpoWLYLVLWN5oxpSnmbi6tGrzqvE1rHwbgxx_gR1nV1ddZ9HWhWqEa0VCh201VNw2v3sqqGFtObCuqLedbYqJhXJedVF0pWd1z2rBtYVrOuGCC15stZ2W1JkUdKdUr3om6KzvYMn0iY9fWnk85dmFinHVbbWqxKSx12sZl-jjPE7BcAud5GEObMatuHiJsmTUxxSdLMskuY3trTzLqkr-xv20W9mSjxslHk8xZF3Ow7Uu5luFfS38Cfsxh74_VFPyXlgn4cREbgR-XZP4NAAD__4mDPL8">