https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98104
Bug ID: 98104 Summary: [11 regression] -Wplacement-new false positive (struture padding?) Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: s...@li-snyder.org Target Milestone: --- hi - With gcc 11 (20201128), the following source (reduced from eigen 3.3.7) gives a warning: -- x.cc --------------------------------------------------------- #include <new> class Base { public: Base(); int* a; char b; }; class Der : public Base {}; void baz() { Der der; ::new (static_cast<Base*>(&der)) Base; } ----------------------------------------------------------------- $ g++ -c x.cc x.cc: In function ‘void baz()’: x.cc:16:10: warning: placement new constructing an object of type ‘Base’ and size ‘16’ in a region of type ‘Base’ and size ‘9’ [-Wplacement-new=] 16 | ::new (static_cast<Base*>(&der)) Base; | ^~~~~~~~~~~~~~~~~~~~~~~~ x.cc:11:7: note: ‘Der::<anonymous>’ declared here 11 | class Der : public Base {}; | ^~~ This appears to be a false positive, possibly due to handling of padding at the end of the structure.