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

    <tr>
        <th>Summary</th>
        <td>
            [clang][StaticAnalyzer] Missing used uninit warning after incomplete zeroing out 
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:static analyzer
      </td>
    </tr>

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

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

<pre>
    Consider the following C++ code where the memset doesn't fully zero out `vec`:
```c++
#define THREADS 32
#define BLOCKS 2

int main() {
  float *vec = NULL;

 vec = (float *)malloc(BLOCKS * THREADS * sizeof(float));
  memset(vec, 0, BLOCKS * THREADS);

  for (int i = 0; i < THREADS * BLOCKS; ++i)
 vec[i] += i;

  printf("%f %f .. %f\n", vec[0], vec[1], vec[BLOCKS * THREADS - 1]);
  free(vec);
  return 0;
}
```
Both clang UninitializedValues and StaticAnalyzer checkers on trunk seemingly miss warning the uninitialized value usage.

Reduced version for UninitializedValues that GCC catches (https://godbolt.org/z/zTn6fE3Yb):
```c++
int main() {
    float *vec = NULL;
    vec = (float*)malloc(64);
    printf("%f", vec[0]);
    free(vec);
    return 0;
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVE1v4zYQ_TWjyyCGPLJk66CDba1boGkLbHYL9EhLI4tdigxIykH86wvSitd2su0CEr-GfJx58zjCOXnQzBXkG8jrRIy-N7YS2hstTWfloWfvTbI37Wu1NdrJli36nrEzSpkXqQ-4BdoAbbAxLeNLz5bjhoEHxx5bw04DLT12o1KveGJr0IweoUiP3ECRQraGtIZ0Hcbxa86I0yplLXdSM3759fOndf2EGd1bNo9_bn97wrf12ErtcRBSA62ASoTlhIfYKSM8Aq2P3CBkNf7x9fERss31aXyzAa0u-4HKQShlGqDVdCXQ-uJXGDt5YtO9HQIqw5ddrj6TArQKodMW09C8h7o-dPHa2OBMCEtGz1LINnG4vfHgjBZsZxZlALvEBPlGQl5HW1ajfHfNs5Xad5E0Aso7jM1sFnvItzqubyesFPL6-2x-M_uAoQc8b7mmpLPMb4Rcr1v2o9UxysnDZX2nk_N0Y3yPjRL6gF-11NJLoeSJ27-EGtmh0C0-eeFls9ZCvZ7YYtNz842tQ6PR21F_Q8c8SH1QrzhI5_BFWB2kHXQ8XmPiMYDi6MSBZ9fEfeZ2bIKdrZNGx2x95I3vhcdftltshG96diGlvffPLrwC2gHtDqbdG-Vnxh6Adqfwf9FF9yn7ex8J-s_H8mPR_5_sw457zd9JvljcZui9WD7Qxu2BHyX7p9KdtFXWllkpEq7mS1pmKyoWlPTVvEjbol1xutgX-1VWrNIyzfJFTmVJ83Y5T2RFKS3SkgpKs3RBs7ItlrTvxGLVFQUVLSxSHoRUM6WOQ6A-kc6NXM3n6bwoEiX2rFwskkRRapCtXRQViklVIfa8TmwVIB7248HBIlXSefcd1EuvYq09Y-Q15JtbbYa3-bt0LqhvdNxO8rsoUnSeLUrdmOFZsedYT4MhlNRktKq6U5P0_bifNWYA2gU_pu7h2Zp_uPFAuxipA9pNwR4r-jcAAP__gDq_Vg">