This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: gcc 6.1.0 bogus placement new warning
- From: Martin Sebor <msebor at gmail dot com>
- To: Jason Mancini <Jason dot Mancini at amd dot com>, gcc-help at gcc dot gnu dot org
- Date: Thu, 26 May 2016 22:01:52 -0600
- Subject: Re: gcc 6.1.0 bogus placement new warning
- Authentication-results: sourceware.org; auth=none
- References: <5747B0B0 dot 7060800 at amd dot com>
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