On 2/25/21 4:40 PM, Jeff Law wrote:


On 2/8/21 3:44 PM, Martin Sebor wrote:

I think the underlying problem is the same.  We're getting a size
that doesn't correspond to what's actually being accessed, and it
happens because of the virtual inheritance.  In pr97595 Jason
suggested to use the decl/type size inequality to identify this
case but I think we could have just as well used DECL_ARTIFICIAL
instead.  At least the test cases from pr97595 both pass with
this change.
OK.  I guess it's a minor question of semantics between pr97595 and
pr98266  being the same.  But I think we can put that behind us now.

I think the big question is whether or not DECL_ARTIFICIAL is the right
way to detect these cases, or if there simply isn't a way as one message
from Jason seems to imply.

DECL_ARTIFICIAL happens to work for the vtbl case but it doesn't work
for other accesses to members of virtual bases  that don't involve
artificial members but where the offset is constant.  I didn't think
those came up but as Jason showed, they do: in accesses in destructors
(and also in some in constructors).  So the DECL_ARTIFICIAL test isn't
the right way to detect all those cases.

I have posted an updated patch that handles those cases as well as
direct vtbl accesses by detecting the COMPONENT_REF (MEM_REF (&d), m))
access to member m of object d with virtual bases, that doesn't depend
on DECL_ARTIFICIAL.

Martin

Reply via email to