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

    <tr>
        <th>Summary</th>
        <td>
            [clang: static analyzer] False positive of clang-analyzer-core.uninitialized.Assign with std::addressof
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:static analyzer,
            new issue
      </td>
    </tr>

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

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

<pre>
    When an uninitialized object has its value set via the result of `std::addressof` either via assignment or placement new, the static analyzer does not recognize that the value is no longer uninitialized since it issues `clang-analyzer-core.uninitialized.Assign` when that object is subsequently used to construct/assign another. See the example below (also shown at https://godbolt.org/z/GMjr4sv9c)

```
#include <memory>

void rejected()
{
    int x;
    *(std::addressof(x)) = 1;
    int y = x;  // warning: Assigned value is garbage or undefined [clang-analyzer-core.uninitialized.Assign]
}

void accepted()
{
    int x;
    *(&x) = 1;
    int y = x;
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVE2TqzYQ_DXDZWpdIIHXHDh41yGnnHLIWaAB9CJLjjTYa__6lMCufc-bw1aqXAZJTKu750PFaEZH1ED1BtUhUzNPPjRm_PtEIeu8vjZ_TeRQOZydcYaNsuZGGn33g3rGSUU0HPGs7EwYifFsFPJEGCjOltEPCNs8sga5B7lXWgeK0Q-wzZEMTxSWiJXHkRyjD3iyqqdl4egC4n0BjKzY9KicstcbBdSeIjrPGKj3ozM3Qp4UL9-udEw6R-vdSOGJfjSuJzSMJsaZYuLYW-XGlwf8S-8DbX4J2uwXkon5JXmy3Hb3wUSMcxfpn5kc2yvOkTSyx967yGHuGUS7akTlfJK9wT-JFrL0oY4nS9iR9RcEsVM2eoyTvzhUjBPzKSb3RAuiHb3uvOWNDyOI9gai_f2PH6GM57oHUUN-gHx__9_m99-6FNK43s6aEOT7kY4-XEH-9nPE2RuNgZIg0iB2n4Cvb-sLIqJxjB8gf9oBsQex-48ci91HwhA1gjxg8UtQgrku-wksgSR5eFHBGTeC3ONqN-nPbI4qdGqkVCKz0zSYdArV27dTVx0egg5fhKu-p9P_EQ5i-_Edjc9XP_KT6UbqWtYqo6bYvsqyyksps6kppJJS58UgcqrKoVO0q0m-DrvqVUnKq8w0IhcyL4qiqEQui0051EKXnayHIhdyq6DM6aiM3Vh7PqaayZZ6b6q6ltvMqo5sXFpfiMVDkPunNgMhQLyDEI4ua7OkneqQhSZhvnTzGKHMrYkcP29hw3aZKQ_U5-6F6oCtspHw5KNhc6Y0Kb6bR7wYnvBrwWVzsM1Tvxie5m7T-yOINvG7P15OwadCB9GuIwBEu7jybwAAAP__9PabXw">