https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67875
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Known to work| |6.1.0 Resolution|--- |DUPLICATE Assignee|unassigned at gcc dot gnu.org |msebor at gcc dot gnu.org Known to fail| |5.3.0 --- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> --- With -Wplacement-new, GCC issues a diagnostic for the buffer overflow in the invocation of the placement new expression (with or without optimization). It doesn't issue a -Warray-bounds warning but that problem is being tracked in bug 67872 so I'll close this as a duplicate of bug 67942. $ cat y.C && /build/gcc-trunk-git/gcc/xgcc -B /build/gcc-trunk-git/gcc -O2 -S -xc++ -Warray-bounds y.C void* operator new (__SIZE_TYPE__, void *p) { return p; } struct A { char a [4]; } a; void foo () { new (&a.a [5]) char; } y.C: In function ‘void foo()’: y.C:9:10: warning: placement new constructing an object of type ‘char’ and size ‘1’ in a region of type ‘char [4]’ and size ‘0’ [-Wplacement-new=] new (&a.a [5]) char; ^~~~~~~~ *** This bug has been marked as a duplicate of bug 67942 ***