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

    <tr>
        <th>Summary</th>
        <td>
            [analyzer] Placement new checker for arrays result in 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>
          isuckatcs
      </td>
    </tr>
</table>

<pre>
    When placement new is used to create and array of elements at a specific location, a warning is falsely reported.
```
#include <new>

struct s {
  int x;
};

int main() {
  s arr[4];
  new (arr + 1) s[1];
  ^~~~~~~~~~~
  warning: 12 bytes is possibly not enough for array allocation which requires 4 bytes. Current overhead requires the size of 8 bytes [cplusplus.PlacementNew]

  return 0;
}
```

The warning is only reported in case of arrays with both `trunk` and `14.0.0` clang.
Writing `new (arr + 1) s` doesn't end up with a warning, but `new (arr + 1) s[1]`, `new (arr + 1) s[2]`, etc. all do. 
Feel free to check the snippet on godbolt: https://godbolt.org/z/dvz9nqPne. Compile only using `--analyze`.

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx9VMlu2zAQ_Rr6MoggU7ZkH3TIeixyKJAzRY4sNjSpcLFrf32HslInRRqA4jbDmcf3huqcOrUvA1oYjZC4RxvB4hF0gBRQQXQgPYqIIKwC4b04gesBzeQaQEQQEEaUutcSjJMiamcZv6fto_BW212O1QsT0JzA4-h8RFWw8oGVt6wu53ZZ8kpbaZJCYNU9wWDV42yZ-hB9khECsObusgOgCfBvVs1r1jxc51Of7XuhCdKG8e3HkyFfh63vVmx9PQTT7cmZbDTcwTKfCuS2_OzG1o-s-bbNjjMLrLqFJYfuFDFkRkYXgu6IEusioHVpN0Dv_EyxMO9UwnHQciDi3pL2dHR1CVHAffI-q-UO6AcU6uoSB4Sgz5iF2swZ6QJyNCnkr3h-l_oHUUy3-kAXUJiYvIXyE6dfqjX1PynZB6Gd_aAyiQNShAnIdK8ARx0H6Bx1FIfktK80TrVF43JVlEVOANIIu5uL5MXrmKPT_tfakL9yGEjiJlOpII2XPH9LMNdjl-L_Q8zy0tXI8xsvfvXCKIusE-Uu4IL0CdFA7xGnZzOgfL1oYfU4IillYedU50zMxTDEOAaaMP5EbTYUzhPYpzN96nDe2rdniyS124_a4IXcFGYybm6EFeZ0RprPVC1UW6lttRWLqKPBlhDPPlToD_D86YlPANFfqy6QcCGZmGWbHmwuUuL-gIvkTfsPYCI4dYV0e1oYc3gfbkbvfqGMtNQhJAw0Wde8Xi2GttkozutGrbe4bLrtmvNVXfUr3m961S97sTCiQxMybMb55TdEIWhO6Be65SXnZc03y7Iql3UhsOz6zarfKMVxUzdsVSI9dVNkHJnJhW8nSF3aBTIaHWK4GgU9wJ3FiaUcX6Q4ON_qkOSriDIspuTtBP4PPmyVUA">