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

David Blaikie dblaikie at gmail.com
Sat Mar 14 19:59:35 PDT 2015


On Mar 14, 2015 6:25 PM, "Tim Northover" <t.p.northover at gmail.com> wrote:
>
> 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).

Clang is pretty good about warning about the technical use of those
functions even if nrvo kicks in and they're never actually needed - older
versions of gcc used to not do this checking, but to I believe now even gcc
catches this.

There may be some holes here, of course...

>
> I'd be interested to know what this other compiler was, too.
>
> Tim.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150314/1be353b3/attachment.html>


More information about the llvm-dev mailing list