<div dir="ltr">And what library implements <span style="font-family:arial,sans-serif;font-size:13px">__dynamic_cast for clang on Linux/OS X? </span></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Feb 25, 2014 at 7:44 PM, David Majnemer <span dir="ltr"><<a href="mailto:david.majnemer@gmail.com" target="_blank">david.majnemer@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>The code that actually performs the dynamic_cast is not actually emitted by the compiler.  The behavior you are seeing is not coming from the compiler but from the __RTDynamicCast function.</div>

<div><br></div><div>Clang's job is to call __RTDynamicCast with the correct arguments, nothing more.</div>
<div><br></div><div>The Itanium ABI, utilized by OS X and Linux, specifies that this cast is performed by __dynamic_cast.  Again, all we do is provide the necessary argument to this function and let the underlying runtime do the rest.</div>


<div><br></div><div>This behavior is not really up to us to emulate.</div><div><br></div><div>Also note that the ability to handle these kinds of memory exceptions happens under the aegis of SEH, making an already heavyweight operation even heavier.</div>

<div class="HOEnZb"><div class="h5">
<div><br></div><div>On Mon Feb 24 2014 at 1:33:35 AM, Domagoj Saric <<a href="mailto:domagoj.saric@littleendian.com" target="_blank">domagoj.saric@littleendian.com</a>> wrote:</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


On 24.2.2014. 7:53, David Majnemer wrote:<br>
> I don't think it would be unreasonable for us to maintain a list of things we do<br>
> and do not claim to support.<br>
<br>
FWIW, MSVC's RTTI implementation has one nice property (which I'd like if Clang<br>
could also 'emulate'): it (dynamic_cast) does not crash on objects w/o an RTTI<br>
record (while Clang under OSX always crashed for me in those cases).<br>
Such a case, for example, often arises if you use a (lame) GUI library which<br>
requires RTTI (because it relies on dynamic_cast and cross-casting) so you<br>
enable RTTI for its sources but disable it for others/your own sources (in order<br>
to minimize bloat and the leaking of internal implementation details as plain<br>
text in the final binary). Then when the GUI lib calls dynamic_cast on one of<br>
your own objects (because you, for example, added it to some widget container)<br>
it will simply get a nullptr result with MSVC (while, as I mentioned, you'll get<br>
a crash with Clang)...<br>
<br>
<br>
<br>
--<br>
Domagoj Saric<br>
Software Architect<br>
<a href="http://www.LittleEndian.com" target="_blank">www.LittleEndian.com</a><br>
______________________________<u></u>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/cfe-dev</a><br>
</blockquote>
</div></div><br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div>