https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96511
Bug ID: 96511 Summary: Incorrect placement-new warning Product: gcc Version: 10.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: mserdarsanli at gmail dot com Target Milestone: --- Below code causes the warning in the last line, which seems to be incorrect. It affects all versions starting from GCC 8 Compiler explorer: https://godbolt.org/z/xhf6cr #include <new> struct Foo { Foo() = default; Foo(int _a) : a(_a) {} int a = 0; }; void f() { Foo arr[2]; new (arr) Foo(10); // ok new (arr + 0) Foo(10); // ok new (&arr[0]) Foo(10); // ok new (&arr[1]) Foo(15); // ok new (arr + 1) Foo(15); // warning: placement new constructing an object of type 'Foo' and size '4' in a region of type 'Foo [2]' and size '0' [-Wplacement-new=] }