[cfe-dev] http://llvm.org/bugs/show_bug.cgi?id=11462
Douglas Gregor
dgregor at apple.com
Sat Dec 3 10:19:43 PST 2011
On Dec 2, 2011, at 12:00 PM, Howard Hinnant wrote:
> I would like to draw clang developer's attention to:
>
> http://llvm.org/bugs/show_bug.cgi?id=11462
>
> This is a feature request for a new intrinsic __is_final(T).
>
> This intrinsic has become necessary due to the recent C++ language addition "final". The problem is that many libraries (such as libc++) will derive from types they know nothing about except that the type is a class and is eligible for the empty base optimization.
>
> libc++ uses this technique in no less than 5 places to optimize away space for allocators, deleters, predicates, etc. It makes all containers smaller, and is what enables sizeof(unique_ptr) == sizeof(void*). I.e. it is a critically important optimization.
>
> Now that our customers can write:
>
> class final A {};
>
> we find ourselves in the position that libc++ will attempt to derive from A in a surprising number of places (because it is empty), only to result in a compile time error because A is also final. Thus libc++ needs a way to check classes for final.
>
> Ganesh has proposed a patch to clang to implement __is_final, complete with a __has_feature check. libc++ really needs this so that our clients can write:
>
> std::tuple<A> t;
>
> Comments? Questions?
FWIW, I've committed Ganesh's patch as Clang r145775. Thanks, Ganesh!
- Doug
More information about the cfe-dev
mailing list