[clang] [analyzer] Fix FP for cplusplus.placement new #149240 (PR #150161)
Balazs Benics via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 23 02:44:00 PDT 2025
steakhal wrote:
> The code that you're removing is not an accidental bug, but an intentional (although perhaps overzealous) feature that tries to warn about the fact that placement new for an array type may allocate an unspecified amount of overhead (extra memory) for internal needs.
>
> According to a quick search this was a significant issue especially in Visual Studio (where it could cause memory corruption), but very recent versions of the standard (C++20 and later) declare that _placement_ new of arrays must not introduce an overhead: https://stackoverflow.com/a/75418614
>
> To improve the usefulness of this checker, I weakly support this change, but I would also like to see a second opinion from @steakhal @Xazax-hun @haoNoQ or other contributors.
I never understood the reasons of having metadata for placement-new. Certainly on linux it was not the case, but I'm skeptical if it was on any other platforms such as Windows. (prove me wrong). But unless it's proved that such a platform exists under some configuration, I see no benefit of having this warning. And even then, we should at least make this diagnostic conditional to only have it for the platforms where it's actually a thing.
https://github.com/llvm/llvm-project/pull/150161
More information about the cfe-commits
mailing list