Boost logo

Boost :

Subject: Re: [boost] [function] Placement new warnings from gcc 6
From: Peter Dimov (lists_at_[hidden])
Date: 2016-04-01 12:37:20


Steven Watanabe wrote:
> On 04/01/2016 02:11 AM, Andrey Semashev wrote:
> >
> > In my tests on gcc 6 I'm seeing these warnings which stem from
> > Boost.Function:
> >
> > ../boost/function/function_template.hpp:572:11: warning: placement new
> > constructing an object of type '<snip>'
> > and size '8' in a region of type 'char' and size '1' [-Wplacement-new=]

> The 'char' in question is the first element of an array of sufficient
> size.

The buffer does have sufficient size but the char is not an array element.
It's a char member of a union.

We could make this clearer by making function_buffer::data be an array with
a sufficient size by, for instance, duplicating the definition of "union
function_buffer" and taking its sizeof... or just by using &functor instead
of &functor.data at line 572, although this might trigger aliasing warnings
with other g++ versions.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk