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

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

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

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

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

<pre>
    With clang-tidy (LLVM version 13.0.0). , this code snipped
```
#include <assert.h>
#include <stdint.h>

#define SIZE 1

void func( int16_t len1, int16_t len2 )
{
    int16_t i;
    float t[SIZE];

    assert( len1 <= SIZE );
    assert( len2 <= len1 );
            
    for ( i = 0; i < len1; i++ )
    {
        t[i] = 1;
    }
            
    for ( i = 0; i < len2; i++ )
    {
        float s = t[0];
        (void) s;
    }
}
```
 causes 
```
1 warning generated.
warning: Assigned value is garbage or undefined [clang-analyzer-core.uninitialized.Assign]
        float s = t[0];
        ^         ~~~~
note: Assuming 'len1' is <= 1
    assert( len1 <= SIZE );
            ^
Taking true branch
    assert( len1 <= SIZE );
    ^
note: Assuming 'len2' is <= 'len1'
    assert( len2 <= len1 );
            ^
note: Taking true branch
    assert( len2 <= len1 );
    ^
note: Assuming 'i' is >= 'len1'
    for ( i = 0; i < len1; i++ )
                 ^~~~~~~~
note: Loop condition is false. Execution continues on line 19
    for ( i = 0; i < len1; i++ )
    ^
note: Assuming 'i' is < 'len2'
    for ( i = 0; i < len2; i++ )
                 ^~~~~~~~
note: Loop condition is true.  Entering loop body
    for ( i = 0; i < len2; i++ )
    ^
note: Assigned value is garbage or undefined
        float s = t[0];
        ^         ~~~~
```

- The assumption `'i' is >= 'len1'` leads with `i = 0` to **len1 <= 0**.
- with `assert( len2 <= len1 )` we assure **len2 <= 0**.
- How can then `'i' is < 'len2'` be assumed? With` i = 0` this leads to **len2 > 0**, which is a contradiction to the first two statements.

In other words: How can the second loop body be ever entered, it the first loop body was not entered, if both loops start with 0, if the index in both loops is incremented by one, and if the number of iterations of the second loop is not larger than the number of iterations of the first loop?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJytVt-P4jgM_mvKizVVmwKlDzzMD0a70uzL7WpXupdT2oY2dyFBSQo7-9ef3VJaOGYOMVtV0MSO_X2O4zg35evyh_Q1FIrr6s7L8hUCtnh5-f4FdsI6aTTESRiFUcCyEEWP4GvpoDClAKfldivKIHoKovtgHh3ebsgSqQvVoFqQPHLnhPVhHSSrS2LnS6lPxL1SKdZSC_j6-c8VxGPZzsgS1o0uEC3g4nj-lwcldEwQR2OGmLPDwvSh-wB8ehUZJKPZtTLcgw9mD-QxmD0dpYNOx4XckjuCHyRPHUJyNTZ3osp61W7ZmWr_jLAYCy05oEURarefjx1LGgXsAd-BYLs-PTNKZCQyaa3EJz6D9OlWAOx6AF1MXWuEwETjsB69sgXtKFoCdxnj8HGaaFDwxgkHF4Ux7LnVUldQCS0s96IMO8lhPkju4d45WWlRwo6rRgBmd8VtzisBGIBGdylYAkLvDgnXXL3-EvauMFaEDZqRXnIlf6HxzhYxvCEGs9WwC-lqeFstbbw4oG02xChgaZfvKUE-5FZ8U56OEHST3_g_5MJbjEduuS7qm-we7b0Bnp2CHxh97Aide72azfv232Ujj1RWb1G57UDDObX00nuC68WYLVZoXWJeYv1GVGuunAhh9VMUTTuHUi91g-cGB4pKbJx9FOmV8Xkcbf5Hi81vCQ7lRQiw0l5YQqtII8eb8cOl8EJArqg0v710nF_N7e8dfKsFpX-z2baRIPl7eTyPkC0vHeypX8BhHwwUeIOaeF_fj0tC1E2Fvb9-3f8cOTS374BZMVhlb1n9ZPZ4BWhsS8R_OZzkGhrOD4wxyMkzUONDs2Mi1Nx0NMecyPuqd00dxr6WRU0-eHuULC9l0UYRVyESWEvrsJHYG3Aeb52N0N6F4_B_1mBQ0cLe2NJRcoyIgBOUoUMmEnCB_RgISlJET02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