[Mesa-dev] [PATCH] i965: Make vec4_visitor's destructor virtual

Iago Toral itoral at igalia.com
Mon Oct 5 03:23:34 PDT 2015


On Mon, 2015-10-05 at 13:08 +0300, Francisco Jerez wrote:
> Iago Toral Quiroga <itoral at igalia.com> writes:
> 
> > We need a virtual destructor when at least one of the class' methods is virtual.
> > Failure to do so leads to undefined behavior when destructing derived classes.
> > Fixes the following warning:
> >
> > brw_vec4_gs_visitor.cpp: In function 'const unsigned int* brw::brw_gs_emit(brw_context*, gl_shader_program*, brw_gs_compile*, void*, unsigned int*)':
> > brw_vec4_gs_visitor.cpp:703:11: warning: deleting object of polymorphic class type 'brw::vec4_gs_visitor' which has non-virtual destructor might cause undefined behaviour [-Wdelete-non-virtual-dtor]
> >     delete gs;
> 
> I don't think this was leading to an actual bug because AFAICT
> gen6_gs_visitor is the only subclass of vec4_visitor destroyed through a
> pointer of a base class (vec4_gs_visitor *), and its destructor is
> basically the same as its parent's.  Anyway it seems sensible to change
> this so it doesn't bite us in the future.  If you clarify that in the
> commit message this patch is:
> 
> Reviewed-by: Francisco Jerez <currojerez at riseup.net>

Will do, thanks Curro!

Iago

> > ---
> >  src/mesa/drivers/dri/i965/brw_vec4.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h
> > index d1fa095..5e3500c 100644
> > --- a/src/mesa/drivers/dri/i965/brw_vec4.h
> > +++ b/src/mesa/drivers/dri/i965/brw_vec4.h
> > @@ -76,7 +76,7 @@ public:
> >  		void *mem_ctx,
> >                  bool no_spills,
> >                  int shader_time_index);
> > -   ~vec4_visitor();
> > +   virtual ~vec4_visitor();
> >  
> >     dst_reg dst_null_f()
> >     {
> > -- 
> > 1.9.1
> >
> > _______________________________________________
> > mesa-dev mailing list
> > mesa-dev at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/mesa-dev




More information about the mesa-dev mailing list