<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Pointers to member functions are very strange animals</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/02/09/70002.aspx</link><description>Pointers to member functions are very strange animals. Warning : The discussion that follows is specific to
the way pointers to member functions are implemented by the
Microsoft Visual C++ compiler. Other compilers may do things
differently. Well, okay,</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: Pointers to member functions are very strange animals</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/02/09/70002.aspx#70010</link><pubDate>Mon, 09 Feb 2004 15:24:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:70010</guid><dc:creator>R</dc:creator><description>'Casting a function pointer can change its size!'&lt;br&gt;&lt;br&gt; Bu..bu.. bu ... my head hurts.</description></item><item><title>re: Pointers to member functions are very strange animals</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/02/09/70002.aspx#70021</link><pubDate>Mon, 09 Feb 2004 15:44:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:70021</guid><dc:creator>Lonnie McCullough</dc:creator><description>I was just wondering about this very subject and was going to post a comment asking you to discuss it.  Wow!  Thanks again, I always wondered why my pointers to member functions had a sizeof() == 8 sometimes and 4 other times.</description></item><item><title>re: Pointers to member functions are very strange animals</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/02/09/70002.aspx#70029</link><pubDate>Mon, 09 Feb 2004 16:02:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:70029</guid><dc:creator>Henk Devos</dc:creator><description>Long ago, when trying to cast a member function pointer to a DWORD, i couldn't believe that the compiler gave me a size mismatch pointer...</description></item><item><title>re: Pointers to member functions are very strange animals</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/02/09/70002.aspx#70034</link><pubDate>Mon, 09 Feb 2004 16:15:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:70034</guid><dc:creator>Curt</dc:creator><description>&amp;gt; The size of a pointer-to-member-function can change depending on the class!&lt;br&gt;&lt;br&gt;As if Mondays aren't hard enough!  I'm going back to bed. :)&lt;br&gt;</description></item><item><title>re: Pointers to member functions are very strange animals</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/02/09/70002.aspx#70056</link><pubDate>Mon, 09 Feb 2004 16:55:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:70056</guid><dc:creator>Jonathan O'Connor</dc:creator><description>My friend and former colleague, Martin O'Riordain came up with the idea of using thunks for ptr-to-member-fn about 1990. He wouldn't tell us about them then, because he wanted to use this for his interview with Microsoft. Its funny to see that they aren't used anymore. But then I guess, C++ has moved on a bit since then.</description></item><item><title>re: Pointers to member functions are very strange animals</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/02/09/70002.aspx#70100</link><pubDate>Mon, 09 Feb 2004 18:22:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:70100</guid><dc:creator>Ben Hutchings</dc:creator><description>The size of a pointer-to-member should not vary as you describe. The C++ standard says it's OK to cast a pointer-to-member-of-derived to pointer-to-member-of-base (though it must be a non-virtual base) so long as you only use the result with pointers-to-base that really point to instances of the derived class. So the &amp;quot;optimisation&amp;quot; of dropping the adjustment field where it's apparently not necessary is actually a bug. The compiler admits:&lt;br&gt;&amp;quot;warning C4407: cast between different pointer to member representations, compiler may generate incorrect code&amp;quot;. Thankfully there is an option that fixes this: &amp;quot;/vmg&amp;quot;. However, the documentation for C4407 and for &amp;quot;/vmg&amp;quot; fails to acknowledge that this behaviour is a bug and basically blames the programmer for finding the edge cases where this &amp;quot;optimisation&amp;quot; doesn't work.</description></item><item><title>re: Pointers to member functions are very strange animals</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/02/09/70002.aspx#70243</link><pubDate>Mon, 09 Feb 2004 21:58:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:70243</guid><dc:creator>Raymond Chen</dc:creator><description>Actually, Ben, if you're referring to 4.11.2 (pointer to member conversions) the standard actually says the opposite. You can convert pointer-to-base-member into pointer-to-derived-member without loss of fidelity. And that's what we're doing here.&lt;br&gt;&lt;br&gt;I can't find a place in the standard where it says that you can safely cast pointer-to-derived-member to pointer-to-base-member.</description></item><item><title>re: Pointers to member functions are very strange animals</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/02/09/70002.aspx#70295</link><pubDate>Tue, 10 Feb 2004 00:44:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:70295</guid><dc:creator>Woon Kiat</dc:creator><description>Hi Raymond, this is a very interesting topic. Is there any book or material you would recommend for further understanding on this topic?</description></item><item><title>re: Pointers to member functions are very strange animals</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/02/09/70002.aspx#70298</link><pubDate>Tue, 10 Feb 2004 00:53:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:70298</guid><dc:creator>Raymond Chen</dc:creator><description>This is all undocumented implementation details, so I doubt there'd be a book on it. You can read Ellis/Stroustrup &amp;quot;The Annotated C++ Reference Manual&amp;quot; to see the design of a completely different way of doing pointers to functions.</description></item><item><title>re: Pointers to member functions are very strange animals</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/02/09/70002.aspx#70320</link><pubDate>Tue, 10 Feb 2004 01:42:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:70320</guid><dc:creator>Woon Kiat</dc:creator><description>What about reference on multiple inheritance? Is there any book you would recommend? Most books just touch the surface and never go deep into it. The concept of MI always confuse me when it comes to the vtable layout and implementation. And the architect of C# decide not to have MI in C#. Do you think MI is a good topic to blog on?</description></item><item><title>re: Pointers to member functions are very strange animals</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/02/09/70002.aspx#70333</link><pubDate>Tue, 10 Feb 2004 02:20:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:70333</guid><dc:creator>Raymond Chen</dc:creator><description>I'm not sure what there is to write about on the subject of multiple inheritance. It's a language feature. The language specification leaves a lot of the details to the implementation, so you shouldn't expect to find a book that details implementation since that's all undocumented and subject to change at any time.</description></item><item><title>re: Pointers to member functions are very strange animals</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/02/09/70002.aspx#70452</link><pubDate>Tue, 10 Feb 2004 06:35:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:70452</guid><dc:creator>Stefan</dc:creator><description>There is an article in MSDN about this:&lt;br&gt;&lt;br&gt;&amp;quot;C++: Under the Hood&amp;quot;, Jan Gray, March 1994&lt;br&gt;&lt;br&gt;&lt;a target="_new" href="http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/dnarvc/html/jangrayhood.asp"&gt;http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/dnarvc/html/jangrayhood.asp&lt;/a&gt;</description></item><item><title>Answer to exercise: Pointer to member function cast</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/02/09/70002.aspx#70640</link><pubDate>Tue, 10 Feb 2004 18:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:70640</guid><dc:creator>The Old New Thing</dc:creator><description /></item><item><title>re: Pointers to member functions are very strange animals</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/02/09/70002.aspx#70871</link><pubDate>Tue, 10 Feb 2004 21:51:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:70871</guid><dc:creator>Ben Hutchings</dc:creator><description>Raymond, I'm talking about explicit conversions (aka casts) which are specified in 5.4/7. 4.11/2 is about standard conversions which can be done implicitly (because they're generally safe).</description></item><item><title>re: Pointers to member functions are very strange animals</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/02/09/70002.aspx#70977</link><pubDate>Wed, 11 Feb 2004 00:20:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:70977</guid><dc:creator>Raymond Chen</dc:creator><description>Ben: Okay I read 5.4/7 and I think you're right. Then again, I'm not a real language lawyer; I just play one on the Internet.</description></item><item><title>re: Pointers to member functions are very strange animals</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/02/09/70002.aspx#74348</link><pubDate>Mon, 16 Feb 2004 20:52:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:74348</guid><dc:creator>Giovanni Bajo</dc:creator><description>Why anybody should care about Rich Hickey's ten-years-old techniques when we have boost::bind and boost::function which works wonderfully as generalized binders and callbacks?</description></item><item><title>Pointers to virtual functions with adjustors</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/02/09/70002.aspx#401492</link><pubDate>Thu, 24 Mar 2005 16:03:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:401492</guid><dc:creator>The Old New Thing</dc:creator><description>Two confusing features that explode when you combine them.</description></item><item><title>Qooiii.com blog  &amp;raquo; Blog Archive   &amp;raquo; Hardly Anybody</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/02/09/70002.aspx#1218591</link><pubDate>Wed, 06 Dec 2006 07:31:07 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1218591</guid><dc:creator>Qooiii.com blog  » Blog Archive   » Hardly Anybody</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://www.qooiii.com/blog/?p=27"&gt;http://www.qooiii.com/blog/?p=27&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>PeousWare - At last, sharing !  &amp;raquo; Blog Archive   &amp;raquo; Member function pointer size in Visual C++</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/02/09/70002.aspx#8786210</link><pubDate>Tue, 29 Jul 2008 02:33:40 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8786210</guid><dc:creator>PeousWare - At last, sharing !  &amp;raquo; Blog Archive   &amp;raquo; Member function pointer size in Visual C++</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://www.peousware.com/?p=11"&gt;http://www.peousware.com/?p=11&lt;/a&gt;&lt;/p&gt;
</description></item></channel></rss>