[Bug c++/67875] missing -Warray-bounds in a default placement new expression, bogus location on an overload
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sat Jul 23 20:36:00 GMT 2016
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 ***
More information about the Gcc-bugs
mailing list