<div dir="ltr">On Mon, Apr 8, 2013 at 5:27 PM, John McCall <span dir="ltr"><<a href="mailto:rjmccall@apple.com" target="_blank">rjmccall@apple.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word"><div><div class="h5"><div>
<div>On Apr 8, 2013, at 5:24 PM, Richard Smith <<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>> wrote:</div><blockquote type="cite"><div dir="ltr">On Mon, Apr 8, 2013 at 11:33 AM, John McCall <span dir="ltr"><<a href="mailto:rjmccall@apple.com" target="_blank">rjmccall@apple.com</a>></span> wrote:<br>
<div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div>On Apr 8, 2013, at 11:08 AM, Reid Kleckner <<a href="mailto:rnk@google.com" target="_blank">rnk@google.com</a>> wrote:<br>


> On Mon, Apr 8, 2013 at 2:02 PM, Timur Iskhodzhanov <<a href="mailto:timurrrr@google.com" target="_blank">timurrrr@google.com</a>> wrote:<br>
>> 2013/4/8 John McCall <<a href="mailto:rjmccall@apple.com" target="_blank">rjmccall@apple.com</a>>:<br>
>>> I also find it curious that MSVC uses a thunk for member pointers, since<br>
>>> the required this-adjustment is already plainly expressible in the member<br>
>>> pointer value.<br>
>> Me too actually.<br>
>> Reid, wdyt?<br>
><br>
> I think it allows them to avoid the union between non-virtual methods<br>
> and virtual methods.  Seems a bit cleaner and more obvious to me, but<br>
> it has tradeoffs in terms of code size at the call site and the number<br>
> of conditional vs. indirect branches that you have to do:<br>
> indirect to thunk and indirect through vtable, vs conditional between<br>
> two indirect calls<br>
<br>
</div>Oh, does MSVC not do the union thing?  They always make a thunk to do<br>
the virtual call?<br>
<br>
If so, this "thunk" is potentially quite a bit more than just a thunk — it may<br>
actually have ABI pointer-equality requirements on it for e.g. member<br>
pointer equality tests.<br></blockquote><div> </div><div>I don't believe there's any need for that -- comparisons on pointers to virtual member functions produce unspecified results (see [expr.eq]p2, second-last sentence).</div>

</div></div></div>
</blockquote></div><br></div></div><div>Oh, interesting.  I guess Itanium made it work because it fell out easily enough to do so.</div></div></blockquote><div><br></div><div style>Even on Itanium, it (arguably) doesn't always work:</div>
<div style><div><br></div><div>struct A { virtual void f() = 0; };</div><div>struct B { virtual void f() = 0; };</div><div>struct C : A, B { virtual void f(); };</div><div>void (C::*af)() = &A::f;</div><div>void (C::*bf)() = &B::f;</div>
<div style>int main() { return af == bf; } // returns 0</div></div></div></div></div>