[cfe-dev] __has_feature coverage

Nikola Smiljanic popizdeh at gmail.com
Thu May 1 21:11:27 PDT 2014


The fix is easy, if the traits are fully implemented?


On Fri, May 2, 2014 at 12:48 AM, Marshall Clow <mclow.lists at gmail.com>wrote:

> Recently, reading llvm/tools/clang/docs/LanguageExtensions.rst, I saw a
> list of type_trait primitives
> supported by clang.
>
> One of them caught my eye: __is_nothrow_constructible  — that could be
> handy for use in libc++.
>
> So I ran a quick test:
>
>         __is_nothrow_constructible(int)
> and it returned true.
>
> Then I tried:
>         __has_feature(is_nothrow_constructible)
> and it returned false.
>
> Well, that’s not useful to me; I need to be able to tell when I can use
> that feature.
> So I whipped up a program to test all of the type_traits listed in that
> file (attached),
> and to see if I can check (using __has_feature) whether or not they are
> implemented.
>
> Turns out that __has_feature returns false for the following type traits:
>
>         __has_feature(is_interface_class) = 0
>         __has_feature(is_destructible) = 0
>         __has_feature(is_nothrow_destructible) = 0
>         __has_feature(is_nothrow_assignable) = 0
>         __has_feature(is_nothrow_constructible) = 0
>
> __is_interface_class is a MS extension; so that’s fine.
> __is_destructible and __is_nothrow_destructible are described as
> “partially implemented”, and attempts to use them fail.
>
> On the other hand:
>         __is_nothrow_constructible(int) returns 1
>         __is_nothrow_assignable(int&, int) returns 1
>
> So these two seem to work (for at least one case)
> It seems to me that we should have feature tests for these type traits if
> we expect people to use them
>
> So, I’d like to see
>         __has_feature(is_nothrow_constructible)
> and     __has_feature(is_nothrow_assignable)
>
> return 1
>
>
> — Marshall
>
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140502/237fd5e4/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: traits.patch
Type: application/octet-stream
Size: 1215 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140502/237fd5e4/attachment.obj>


More information about the cfe-dev mailing list