On Mon, Jun 24, 2019 at 12:40 PM Jason Merrill <ja...@redhat.com> wrote:
> On Mon, Jun 24, 2019 at 11:57 AM Jan Hubicka <hubi...@ucw.cz> wrote:
> >
> > > > > As
> > > > >
> > > > >   class a var;
> > > > >   class b:a {} *bptr;
> > > > >
> > > > >   var.foo;
> > > > >
> > > > > Expanding this as var.as_base_a.foo would make access path oracle to
> > > > > disambiguate it from bptr->as_base_b->as_base_a.foo which is wrong 
> > > > > with
> > > > > gimple memory moel where we allow placement new replacing var by
> > > > > instance of b.
> > >
> > > Why do we allow that?  I would expect that to only be allowed if a is
> > > something like aligned_storage, i.e. a thin wrapper around a char/byte
> > > buffer.
> >
> > I think because Richard defined gimple memory model this way after fair
> > amount of frustration from placement news, stack slot sharing issues
> > and non-conforming codebases :)
> >
> > I think for normal user variables this is overly conservative.
> > At the moment TBAA is bit of a mess. Once it is cleaned up, we could
> > see if restricting this more pays back and then we would need to
> > find way to pass the info to middle-end (as it does not
> > know difference between aligned_storage and other stuff).
>
> I thought I remembered someone's recent-ish work to treat specially
> types containing a char array, but I'm not finding it now.

Specifically, aligned_storage has a first member which is a char
array, and a char array can alias anything, so we can put anything in
a char array, and a class can alias its first member, so transitively
we can put anything in such a class.

Jason

Reply via email to