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

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

    <tr>
      <th>Labels</th>
      <td>
      </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>
#include <stdbool.h>

#define SIZE 2

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

    assert( len1 > 0 );
    assert( len1 <= SIZE );

    assert( len1 % 2 == false );

    for ( i = 0; i < len1/2; i++ )
    {
        t[i] = 1;
    }
    
    for (      ; i < len1; i++ )
    {
        t[i] = 1;
    }
            
    assert( len2 <= len1 );

    for ( i = 0; i < len2; i++ )
    {
        float s = t[i];
        (void) s;
    }
}
```
causes
```
warning: Assigned value is garbage or undefined [clang-analyzer-core.uninitialized.Assign]
        float s = t[i];
        ^         ~~~~
note: Assuming 'len1' is > 0
    assert( len1 > 0 );
            ^
note: Taking true branch
    assert( len1 > 0 );
    ^
note: Assuming 'len1' is <= 2
    assert( len1 <= SIZE );
            ^
note: Taking true branch
    assert( len1 <= SIZE );
    ^
note: Assuming the condition is true
    assert( len1 % 2 == false );
            ^
note: Taking true branch
    assert( len1 % 2 == false );
    ^
note: Assuming the condition is true
    for ( i = 0; i < len1/2; i++ )
                 ^~~~~~~~~~
note: Loop condition is true.  Entering loop body
    for ( i = 0; i < len1/2; i++ )
    ^
note: Assuming the condition is true
    for ( i = 0; i < len1/2; i++ )
                 ^~~~~~~~~~
note: Loop condition is true.  Entering loop body
    for ( i = 0; i < len1/2; i++ )
    ^
note: Assuming the condition is false
    for ( i = 0; i < len1/2; i++ )
                 ^~~~~~~~~~
note: Loop condition is false. Execution continues on line 22
    for ( i = 0; i < len1/2; i++ )
    ^
note: 'i' is >= 'len1'
    for (      ; i < len1; i++ )
                 ^
note: Loop condition is false. Execution continues on line 27
    for (      ; i < len1; i++ )
    ^
note: Assuming 'len2' is <= 'len1'
    assert( len2 <= len1 );
            ^
note: Taking true branch
    assert( len2 <= len1 );
    ^
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: 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: The value 2 is assigned to 'i'
    for ( i = 0; i < len2; 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[i];

```
If I am not mistaken, the assertions make len1=2 the only valid value (larger 0, smaller or equal 2, even). Why the hell is it then assumed, that the first loop is entered twice, whereas the second loop is not entered at all, if the first loop stops at len1/2 =1? Iianm, both loops should be passed the same number of times, as long as len1 is even, or not?

Not to mention, that len2 must not be larger than len1, making it impossible that the third loop is entered with i = 2 ...
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztWFFv4jgQ_jXhZdQoOITAAw8tUKlS7x5uT7fSvZycxBDvOjYXO_S6v_5mHFKgQFtaVtqHRpHA8Xjm-76Mx3YyUzxOvkpXQq64Xl45WTxCwEb393_9BmtRW2k09OMwCqOAjUPsmoIrpYXcFAKslquVKIJoFkTXwTDa3G2TxVLnqkGzIJ5ya0XtwjKI58e6rSukfrE7M0bt9ndWhVhILeDL3d9zYLt9ayMLWDQ6RzaAzvvDfxwooftEYafNkNN4MzC9af8AXp2JDOKdpwtluAMXJDcUMUhmT71bm5YrhaVwiH8OkQ-y6-j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