[LLVMdev] FreeBSD's 11.0-CURRENT contrib/llvm/include/llvm/ADT/IntrusiveRefCntPtr.h's IntrusiveRefCntPtr and its use violates C++ privacy rules

Tim Northover t.p.northover at gmail.com
Sat Mar 14 18:25:20 PDT 2015


On 14 March 2015 at 17:55, David Blaikie <dblaikie at gmail.com> wrote:
> 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?

Probably RVO related. The problematic constructor (and it does seem
pointless) is only invoked if an actual copy is needed. Clang takes
advantage of RVO even at -O0 and only ever calls
llvm::IntrusiveRefCntPtr<clang::ExternalSemaSource>::IntrusiveRefCntPtr(clang::ExternalSemaSource*).

If so, I suspect LLVM does need to be changed to work on compilers
without RVO too (the standard says implementations *may* perform that
optimisation, not that they must).

I'd be interested to know what this other compiler was, too.

Tim.



More information about the llvm-dev mailing list