<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Done: #<span class="Apple-style-span" style="font-family: -webkit-sans-serif; font-size: 16px; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; "><a href="http://llvm.org/bugs/show_bug.cgi?id=3752" style="color: rgb(0, 51, 153); ">3752</a></span></div><div><br></div><br><div><div>Le 7 mars 09 à 20:55, Fariborz Jahanian a écrit :</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Behavior should match gcc's.<br><br>Please file a bugzilla with a test case.<br><br>- fariborz<br><br><br><br><br><br>On Mar 7, 2009, at 10:52 AM, Jean-Daniel Dupas wrote:<br><br><blockquote type="cite">Hello,<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">I have a question about the behavior of the @encode compiler directive<br></blockquote><blockquote type="cite">in Obj-C.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">If we where talking about another language the answer would probably<br></blockquote><blockquote type="cite">be: read the spec, unfortunately, there is not Obj-C spec.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">From the Objective-C 2.0 Programming Language:<br></blockquote><blockquote type="cite"><span class="Apple-tab-span" style="white-space:pre">       </span>@encode(type_spec) <span class="Apple-tab-span" style="white-space:pre"> </span>Yields a character string that encodes the type<br></blockquote><blockquote type="cite">structure of type_spec.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><a href="http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/chapter_950_section_5.html">http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/chapter_950_section_5.html</a><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">So we could think that the clang implementation is fine, but here come<br></blockquote><blockquote type="cite">the bad news.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Some widely used testing framework (SenTestingKit which is part of the<br></blockquote><blockquote type="cite">Xcode distribution for example) use this kind of test<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">if (@encode(__typeof__(a1)) != @encode(__typeof__(a2))) {<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">}<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Yep, @encoded "returns" a character string, and these strings are<br></blockquote><blockquote type="cite">compared using == (or != ) and not strcmp, and it works quite well<br></blockquote><blockquote type="cite">using GCC because GCC generates only one const string per type.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">As you want that clang be as much compatible as possible with 'GCC', I<br></blockquote><blockquote type="cite">think something should be done about this issue.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">And if the Obj-C ref is not updated to guarantee that the returns<br></blockquote><blockquote type="cite">value can be compared using ==, I think you may also add a warning.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">_______________________________________________<br></blockquote><blockquote type="cite">cfe-dev mailing list<br></blockquote><blockquote type="cite"><a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br></blockquote><blockquote type="cite"><a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br></blockquote><br><br></div></blockquote></div><br></body></html>