<div dir="ltr"><div><div><div><div><div>I see, thanks for the explanation.. maybe some warning can be issued when this happens? It makes the typeinfo <br>of ptr to incomplete type basically useless in clang, whereas it works fine with other compilers <br>(gcc makes it weak external for example)<br></div><br></div>I feel it's a rather weird pitfall that will cause runtime errors and it's very easy to diagnose for compilers, though<br></div>there might be usecases I don't understand of course<br><br></div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Jan 23, 2017 at 8:06 PM Vedant Kumar <<a href="mailto:vsk@apple.com">vsk@apple.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">It looks like getTypeInfoLinkage (ItaniumCXXABI.cpp) can return 'linkonce_odr'<br class="gmail_msg">
if SomeClass has a definition, and returns 'internal' otherwise. The rationale<br class="gmail_msg">
is that type info for incomplete types must be kept separate from the type info<br class="gmail_msg">
for complete types. IIUC we do this because inkonce_odr definitions can be used<br class="gmail_msg">
by optimizations at any point, so the correct/full definition needs to be<br class="gmail_msg">
available up front.<br class="gmail_msg">
<br class="gmail_msg">
I'm CC'ing David since he wrote the comment, and can probably correct me if I<br class="gmail_msg">
got this wrong.<br class="gmail_msg">
<br class="gmail_msg">
best,<br class="gmail_msg">
vedant<br class="gmail_msg">
<br class="gmail_msg">
> On Jan 22, 2017, at 5:52 AM, Douwe Gelling <<a href="mailto:douwegelling@gmail.com" class="gmail_msg" target="_blank">douwegelling@gmail.com</a>> wrote:<br class="gmail_msg">
><br class="gmail_msg">
> I've reproduced it both on the system clang:<br class="gmail_msg">
><br class="gmail_msg">
> Apple LLVM version 8.0.0 (clang-800.0.42.1)<br class="gmail_msg">
><br class="gmail_msg">
> and on a newer clang installed with homebrew:<br class="gmail_msg">
><br class="gmail_msg">
> clang version 3.9.1 (tags/RELEASE_391/final)<br class="gmail_msg">
> Target: x86_64-apple-darwin16.3.0<br class="gmail_msg">
><br class="gmail_msg">
> In llvm ir, it's marked internal constant with both compilers as well<br class="gmail_msg">
><br class="gmail_msg">
> On Fri, Jan 20, 2017 at 6:23 PM Vedant Kumar <<a href="mailto:vsk@apple.com" class="gmail_msg" target="_blank">vsk@apple.com</a>> wrote:<br class="gmail_msg">
> What version of clang are you using?<br class="gmail_msg">
><br class="gmail_msg">
> I tried referring to the typeid of SomeClass* from two different compilation<br class="gmail_msg">
> units and ended up with just one copy of __ZTSP9SomeClass in my binary. The<br class="gmail_msg">
> symbol is marked as 'linkonce_odr constant' in LLVM IR, which checks out.<br class="gmail_msg">
><br class="gmail_msg">
> $ nm -m t | grep ZTSP9SomeClass<br class="gmail_msg">
> 0000000100001f60 (__TEXT,__const) weak external __ZTSP9SomeClass<br class="gmail_msg">
><br class="gmail_msg">
> best,<br class="gmail_msg">
> vedant<br class="gmail_msg">
><br class="gmail_msg">
> > On Jan 20, 2017, at 5:15 AM, Douwe Gelling via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" class="gmail_msg" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<br class="gmail_msg">
> ><br class="gmail_msg">
> > Hi all,<br class="gmail_msg">
> ><br class="gmail_msg">
> > When taking the typeinfo of a pointer to incomplete type, clang++ emits type info for the pointer in the resulting binary, but makes that typeinfo non-external (on osx at least). Is this intended? I'd have expected it to be weak external so that when the type is defined in other compilation units, the typeinfo isn't defined multiple times.<br class="gmail_msg">
> ><br class="gmail_msg">
> > sample code:<br class="gmail_msg">
> ><br class="gmail_msg">
> > #include <typeinfo><br class="gmail_msg">
> > #include <iostream><br class="gmail_msg">
> > class SomeClass;<br class="gmail_msg">
> ><br class="gmail_msg">
> > int main()<br class="gmail_msg">
> > {<br class="gmail_msg">
> > std::cout << typeid(SomeClass*).name() << std::endl;<br class="gmail_msg">
> > }<br class="gmail_msg">
> ><br class="gmail_msg">
> > when running nm -m on the resulting binary, it contains:<br class="gmail_msg">
> ><br class="gmail_msg">
> > 0000000000000414 (__TEXT,__const) non-external __ZTSP9SomeClass<br class="gmail_msg">
> ><br class="gmail_msg">
> > _______________________________________________<br class="gmail_msg">
> > cfe-dev mailing list<br class="gmail_msg">
> > <a href="mailto:cfe-dev@lists.llvm.org" class="gmail_msg" target="_blank">cfe-dev@lists.llvm.org</a><br class="gmail_msg">
> > <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" class="gmail_msg" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br class="gmail_msg">
><br class="gmail_msg">
<br class="gmail_msg">
</blockquote></div>