On May 29, 2012, at 3:57 AM, r4start wrote:
> This patch fixes the following problem:
> struct first {
>     virtual void asdf() {}
>     virtual void g(){}
>     };
>     
>   struct second : virtual first {
>     int q;
>       virtual void asdf() { q = 90; }
>       virtual void g(){ q = 12; }
>   };
>     
>   struct third : virtual second {};
>     void test2() { third *t; }
> 
> In clang "second" has vtordisp for "first", but MSVC doesn`t generate 
> vtordisp for "first".
> According msdn " If a derived class overrides a virtual function that it 
> inherits from a virtual base class, and if a constructor or destructor for 
> the derived class calls that function using a pointer to the virtual base 
> class, the compiler may introduce additional hidden "vtordisp" fields into 
> classes with virtual bases. ".
> So in in this example "second" will not have vtordisp for "first". But if we 
> add constructor or destructor in "second" then MSVC add vtordisp.

Is this the rule used by MSVC?  For example, does a vtordisp still get emitted 
even if a ctor "obviously" doesn't call any virtual functions, like if it's 
defined in the class definition and obviously empty?  Please test both an empty 
ctor and an empty dtor.

Please also add testcases verifying that we do the right thing in 
further-derived classes that provide ctors.  For example:
  struct A { virtual void foo(); };
  struct B : virtual A { virtual void foo(); }; // no vtordisp
  struct Test1 : B { Test1(); };
  struct Test2 : virtual B { Test2(); };
  struct Test3 : B { Test3(); virtual void foo(); };
  struct Test4 : virtual B { Test4(); virtual void foo(); };
  
John.
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to