<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Dumping a C++ object&#8217;s memory layout with Clang</title>
	<atom:link href="http://eli.thegreenplace.net/2012/12/17/dumping-a-c-objects-memory-layout-with-clang/feed/" rel="self" type="application/rss+xml" />
	<link>http://eli.thegreenplace.net/2012/12/17/dumping-a-c-objects-memory-layout-with-clang/</link>
	<description>Eli Bendersky&#039;s personal website</description>
	<lastBuildDate>Sat, 25 May 2013 12:58:27 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
	<item>
		<title>By: eliben</title>
		<link>http://eli.thegreenplace.net/2012/12/17/dumping-a-c-objects-memory-layout-with-clang/comment-page-1/#comment-1061746</link>
		<dc:creator>eliben</dc:creator>
		<pubDate>Sun, 13 Jan 2013 22:35:14 +0000</pubDate>
		<guid isPermaLink="false">http://eli.thegreenplace.net/?p=3023#comment-1061746</guid>
		<description>@Wilfred,

Good question - I noticed this also. Actually I don&#039;t know the exact cases in which Clang prints out the layout - maybe it makes sense to ask in the cfe-dev list.</description>
		<content:encoded><![CDATA[<p>@Wilfred,</p>
<p>Good question &#8211; I noticed this also. Actually I don&#8217;t know the exact cases in which Clang prints out the layout &#8211; maybe it makes sense to ask in the cfe-dev list.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Wilfred</title>
		<link>http://eli.thegreenplace.net/2012/12/17/dumping-a-c-objects-memory-layout-with-clang/comment-page-1/#comment-1061712</link>
		<dc:creator>Wilfred</dc:creator>
		<pubDate>Sun, 13 Jan 2013 21:16:12 +0000</pubDate>
		<guid isPermaLink="false">http://eli.thegreenplace.net/?p=3023#comment-1061712</guid>
		<description>Hi Eli,

Very helpful post, thanks. Do you have any idea why &quot;sizeof&quot; is required in order to get the object&#039;s layout? If the class is not instantiated with the &quot;new&quot; keyword, or its size is not checked in the code, its layout won&#039;t be printed at all. For example, the following example succeeds:

`&lt;code&gt;struct s { bool b; };

int main(){
	s *p = new s;
	return 1;
}&lt;/code&gt;`

The layout of the struct &quot;s&quot; is printed correctly. But this won&#039;t work:

`&lt;code&gt;struct s { bool b; };

int main(){
	s o;
	s *op = __abENT__amp;o;
	return 1;
}&lt;/code&gt;`

I get no output at all from &quot;clang -cc1 -fdump-record-layouts test.cpp&quot; in this case. Is this a bug in the clang frontend?</description>
		<content:encoded><![CDATA[<p>Hi Eli,</p>
<p>Very helpful post, thanks. Do you have any idea why &#8220;sizeof&#8221; is required in order to get the object&#8217;s layout? If the class is not instantiated with the &#8220;new&#8221; keyword, or its size is not checked in the code, its layout won&#8217;t be printed at all. For example, the following example succeeds:</p>
<div class="backtick"><pre><code>struct s { bool b; };

int main(){
	s *p = new s;
	return 1;
}</code></pre></div>
<p>The layout of the struct &#8220;s&#8221; is printed correctly. But this won&#8217;t work:</p>
<div class="backtick"><pre><code>struct s { bool b; };

int main(){
	s o;
	s *op = &amp;o;
	return 1;
}</code></pre></div>
<p>I get no output at all from &#8220;clang -cc1 -fdump-record-layouts test.cpp&#8221; in this case. Is this a bug in the clang frontend?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: eliben</title>
		<link>http://eli.thegreenplace.net/2012/12/17/dumping-a-c-objects-memory-layout-with-clang/comment-page-1/#comment-1048009</link>
		<dc:creator>eliben</dc:creator>
		<pubDate>Wed, 26 Dec 2012 21:52:47 +0000</pubDate>
		<guid isPermaLink="false">http://eli.thegreenplace.net/?p=3023#comment-1048009</guid>
		<description>@Eden,

Fixed, thanks.</description>
		<content:encoded><![CDATA[<p>@Eden,</p>
<p>Fixed, thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eden Cohen</title>
		<link>http://eli.thegreenplace.net/2012/12/17/dumping-a-c-objects-memory-layout-with-clang/comment-page-1/#comment-1047727</link>
		<dc:creator>Eden Cohen</dc:creator>
		<pubDate>Wed, 26 Dec 2012 14:28:24 +0000</pubDate>
		<guid isPermaLink="false">http://eli.thegreenplace.net/?p=3023#comment-1047727</guid>
		<description>Small typo (how can it be - isn&#039;t this the output of clang ?):
In the first dump [int foo] is shown as [int f]</description>
		<content:encoded><![CDATA[<p>Small typo (how can it be &#8211; isn&#8217;t this the output of clang ?):<br />
In the first dump [int foo] is shown as [int f]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marek</title>
		<link>http://eli.thegreenplace.net/2012/12/17/dumping-a-c-objects-memory-layout-with-clang/comment-page-1/#comment-1042676</link>
		<dc:creator>Marek</dc:creator>
		<pubDate>Wed, 19 Dec 2012 14:33:22 +0000</pubDate>
		<guid isPermaLink="false">http://eli.thegreenplace.net/?p=3023#comment-1042676</guid>
		<description>To make the output of VC readable use undname.exe to it.</description>
		<content:encoded><![CDATA[<p>To make the output of VC readable use undname.exe to it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marek</title>
		<link>http://eli.thegreenplace.net/2012/12/17/dumping-a-c-objects-memory-layout-with-clang/comment-page-1/#comment-1042661</link>
		<dc:creator>Marek</dc:creator>
		<pubDate>Wed, 19 Dec 2012 14:09:54 +0000</pubDate>
		<guid isPermaLink="false">http://eli.thegreenplace.net/?p=3023#comment-1042661</guid>
		<description>If you are using Visual Studio, you can print the same using undocumented /d1reportAllClassLayout switch:
`&lt;code&gt;class Derived   size(40):
        +---
        &#124; +--- (base class Base)
 0      &#124; &#124; foo
        &#124; +---
 4      &#124; bar
 8      &#124; baz
        &#124; __abENT__lt;alignment member__abENT__gt; (size=4)
16      &#124; Point a_point
32      &#124; c
        &#124; __abENT__lt;alignment member__abENT__gt; (size=7)
        +---&lt;/code&gt;`
and second example:
`&lt;code&gt;class Derived   size(40):
        +---
        &#124; +--- (base class Base)
 0      &#124; &#124; {vfptr}
 4      &#124; &#124; foo
        &#124; +---
 8      &#124; bar
12      &#124; baz
16      &#124; Point a_point
32      &#124; c
        &#124; __abENT__lt;alignment member__abENT__gt; (size=7)
        +---
Derived::$vftable@:
        &#124; __abENT__amp;Derived_meta
        &#124;  0
 0      &#124; __abENT__amp;Derived::method

Derived::method this adjustor: 0&lt;/code&gt;`</description>
		<content:encoded><![CDATA[<p>If you are using Visual Studio, you can print the same using undocumented /d1reportAllClassLayout switch:<br />
<code class="backtick">class Derived   size(40):<br />
        +---<br />
        | +--- (base class Base)<br />
 0      | | foo<br />
        | +---<br />
 4      | bar<br />
 8      | baz<br />
        | &lt;alignment member&gt; (size=4)<br />
16      | Point a_point<br />
32      | c<br />
        | &lt;alignment member&gt; (size=7)<br />
        +---</code><br />
and second example:<br />
<code class="backtick">class Derived   size(40):<br />
        +---<br />
        | +--- (base class Base)<br />
 0      | | {vfptr}<br />
 4      | | foo<br />
        | +---<br />
 8      | bar<br />
12      | baz<br />
16      | Point a_point<br />
32      | c<br />
        | &lt;alignment member&gt; (size=7)<br />
        +---<br />
Derived::$vftable@:<br />
        | &amp;Derived_meta<br />
        |  0<br />
 0      | &amp;Derived::method</p>
<p>Derived::method this adjustor: 0</code></p>
]]></content:encoded>
	</item>
</channel>
</rss>
