[PATCH] Zero vptr in dtor for -fsanitize=vptr.

Jakub Jelinek jakub@redhat.com
Fri Oct 27 18:22:00 GMT 2017


On Fri, Oct 27, 2017 at 02:10:10PM -0400, Jason Merrill wrote:
> On Fri, Oct 27, 2017 at 9:52 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> > On Fri, Oct 27, 2017 at 03:48:41PM +0200, Martin Liška wrote:
> >> --- a/gcc/cp/decl.c
> >> +++ b/gcc/cp/decl.c
> >> @@ -14639,8 +14639,12 @@ implicit_default_ctor_p (tree fn)
> >>  /* Clobber the contents of *this to let the back end know that the object
> >>     storage is dead when we enter the constructor or leave the destructor.  */
> >>
> >> +/* Clobber or zero (depending on CLOBBER_P argument) the contents of *this
> >> +   to let the back end know that the object storage is dead
> >> +   when we enter the constructor or leave the destructor.  */
> >> +
> >>  static tree
> >> -build_clobber_this ()
> >> +build_this_constructor (bool clobber_p)
> >
> > I think build_clobber_this is better name, but will defer final review
> > to Jason or Nathan.  Also, seems there was already a function comment
> > and you've added yet another one, instead of ammending the first one.
> 
> Agreed.
> 
> If the point is to clear the vptr, why are you also clearing the rest
> of the object?

Can there be multiple vptr pointers in the object or is there just one?
Even if there can be multiple, perhaps earlier destructors would
have cleared those other vptr pointers though.

	Jakub



More information about the Gcc-patches mailing list