[PATCH] MS ABI: Give thunks linkonce_odr linkage

Reid Kleckner rnk at google.com
Mon Jun 2 12:48:02 PDT 2014

I think it's handling this corner case:
  struct Incomplete;
  struct A { int a; virtual A *bar(); };
  struct B { int b; virtual B *foo(Incomplete); };
  struct C : A, B { int c; virtual C *foo(Incomplete); };
  C c;

MSVC gives this error:
  t.cpp(5) : error C2664: 'C *C::foo(Incomplete)' : cannot convert argument 1 from 'Incomplete' to 'Incomplete'
        Source or target has incomplete type
        This diagnostic occurred in the compiler generated function 'B *C::foo(Incomplete)'

Clang on the other hand relies on the TU defining the virtual function to emit code for the thunk.  Therefore I think the correct linkage is weak_odr.  This should also be applicable to the Itanium C++ ABI.


More information about the cfe-commits mailing list