<div dir="ltr">I assume there's a bit more to it than this - otherwise we would've discovered it earlier? Which compiler is rejecting this code? Do you have a reduced example of something that clang accepts and this other compiler rejects?</div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Mar 14, 2015 at 5:36 PM, Mark Millard <span dir="ltr"><<a href="mailto:markmi@dsl-only.net" target="_blank">markmi@dsl-only.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">When trying to build the 11.0-CURRENT clang 3.5 on powerpc64 I ran into a violation of C++ accessibility rules (for private) that stopped the compile. So not the usual defect category. (This was a bootstrapping procedure as powerpc/powerpc64 FreeBSD world’s clang has an odd status and getting from 3.4 under 10.1-STABLE to 3.5 on 11.0-CURRENT is not automatic.)<br>
<br>
Given the language rules and difficulty interpreting them I figured an open discussion area might be the better place to go until/unless someone from llvm agrees with the information. I'm not sure what priority being non-standard has for points other compilers have trouble with for the code.<br>
<br>
I have looked on the web and Revision 232289 of IntrusiveRefCntPtr.h still has the same code structure for the issue.<br>
<br>
<br>
The problem...<br>
<br>
FreeBSD 11.0-CURRENT's contrib/llvm/include/llvm/ADT/IntrusiveRefCntPtr.h has...<br>
<br>
  template <typename T><br>
  class IntrusiveRefCntPtr {<br>
    T* Obj;<br>
<br>
  public:<br>
  ...<br>
    template <class X><br>
    IntrusiveRefCntPtr(IntrusiveRefCntPtr<X>&& S) : Obj(S.get()) {<br>
      S.Obj = 0;<br>
    }<br>
  ...<br>
  }<br>
<br>
To first illustrate a (partial) but-simpler-to-follow example use that would show the problem with the above:<br>
<br>
using Ta = ...;<br>
using Tb = ...;// Not the same type, more than just a name change.<br>
<br>
// Note that private members of IntrusiveRefCntPtr<Ta><br>
// are not (should not be) accessible to<br>
// IntrusiveRefCntPtr<Tb> methods (and vice-versa).<br>
<br>
IntrusiveRefCntPtr<Ta> a{}<br>
<br>
IntrusiveRefCntPtr<Tb> b{a};<br>
<br>
// We then would have a usage where an example of:<br>
<br>
IntrusiveRefCntPtr<Tb>::IntrusiveRefCntPtr<br>
<br>
is then trying to access an example of<br>
<br>
IntrusiveRefCntPtr<Ta>'s Obj private member.<br>
<br>
It would take a friend relationship to be established to allow the cross-type access to Obj.<br>
<br>
<br>
The code in contrib/llvm/tools/clang/lib/Frontend/ChainedIncludesSource.cpp has such a use and so makes an instance of the violation of the language rules in the actual code.<br>
<br>
The function clang::createChainedIncludesSourceIt uses classes...<br>
<br>
class ChainedIncludesSource : public ExternalSemaSource<br>
where...<br>
class ExternalSemaSource : public ExternalASTSource<br>
where...<br>
class ExternalASTSource : public RefCountedBase<ExternalASTSource><br>
where...<br>
template <class Derived> class RefCountedBase;<br>
<br>
and it uses both of the following types...<br>
<br>
IntrusiveRefCntPtr<ExternalSemaSource><br>
and...<br>
IntrusiveRefCntPtr<ChainedIncludesSource><br>
<br>
In fact IntrusiveRefCntPtr<ChainedIncludesSource> is the return-expresison type for the following routine that has return type IntrusiveRefCntPtr<ExternalSemaSource>...<br>
<br>
IntrusiveRefCntPtr<ExternalSemaSource> clang::createChainedIncludesSource(<br>
    CompilerInstance &CI, IntrusiveRefCntPtr<ExternalSemaSource> &Reader) {<br>
...<br>
  IntrusiveRefCntPtr<ChainedIncludesSource> source(new ChainedIncludesSource());<br>
...<br>
  return source;<br>
}<br>
<br>
===<br>
Mark Millard<br>
markmi at <a href="http://dsl-only.net" target="_blank">dsl-only.net</a><br>
<br>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</blockquote></div><br></div>