This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gcc 6.1.0 bogus placement new warning


On 05/26/2016 08:28 PM, Jason Mancini wrote:
It seems if you have an array of pointers, and attempt:

   object* TheArray[2];
   TheArray[x] = (object*) malloc(NUM * sizeof(object));
   new (TheArray[x] + num) object(...);

The check uses size of TheArray (16 bytes), and not the large allocation
which TheArray[x] points to.  Known bug?  Easy to work around with a
temp variable at least.

error: placement new constructing an object of type '...' and size '120'
in a region of type 'object* [2] {...* [2]}' and size at most '16'
[-Werror=placement-new=]

It does look like a new problem.  I raised bug 71306 for it.

Thanks
Martin


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]