https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71306

            Bug ID: 71306
           Summary: bogus -Wplacement-new with an array element
           Product: gcc
           Version: 6.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

As reported in the following post:

  https://gcc.gnu.org/ml/gcc-help/2016-05/msg00113.html

the -Wplacement-new warning introduced in GCC 6.1 issues a false positive on
the following test case.  It seems to treat the array element as if it was the
array itself.

$ cat zz.cpp && /build/gcc-6-branch/gcc/xgcc -B /build/gcc-6-branch/gcc -S
-Wall -Wextra zz.cpp
void* operator new (__SIZE_TYPE__, void *p) { return p; }

struct S { char c [32]; } *p [2];

void f ()
{
  new (p [0]) S;
}
zz.cpp: In function ‘void f()’:
zz.cpp:7:12: warning: placement new constructing an object of type ‘S’ and size
‘32’ in a region of type ‘S* [2]’ and size ‘16’ [-Wplacement-new=]
   new (p [0]) S;
        ~~~~^

Reply via email to