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

--- Comment #25 from rguenther at suse dot de <rguenther at suse dot de> ---
On Tue, 28 Feb 2017, bernd.edlinger at hotmail dot de wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79671
> 
> --- Comment #24 from Bernd Edlinger <bernd.edlinger at hotmail dot de> ---
> (In reply to Richard Biener from comment #23)
> > (In reply to Bernd Edlinger from comment #22)
> > > (In reply to Jakub Jelinek from comment #20)
> > > > which fails also on x86_64-linux at -O2.  And that testcase regressed 
> > > > with
> > > > r223126.  Now whether this is valid C++, no idea, placement new is 
> > > > messy.
> > > 
> > > This test case can't be valid, suppose the A has a copy constructor
> > > that that is also not called when B is moved around.
> > 
> > The canonical fix is to put the type you placement new into the union 
> > storage
> > into the union as regular member rather than having a char[] member in the
> > union.
> 
> Yes. Of course you cannot put a non-POD type in a union,
> but maybe a pointer to A, that is probably what boost should
> do in their functor class.

You can put a non-POD into a union but then you need to provide
copy/move/etc. constructors as they are otherwise default deleted.

Reply via email to