[cfe-dev] clang++: std::is_aggregate unusable with clang-5.0/libstdc++-7

Richard Smith via cfe-dev cfe-dev at lists.llvm.org
Fri Jul 7 12:50:24 PDT 2017


On 7 July 2017 at 00:23, Katsuhiko Nishimra via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> Dear developers,
>
> As of r307243, clang++ seems to have the __is_aggregate() builtin
> macro, but __has_builtin(__is_aggregate) returns false.  This is
> rendering std::is_aggregate from libstdc++-7 unusable with clang++.
>

__has_builtin detects builtin functions. __is_aggregate is not a builtin
function -- it's not a function at all, since it takes a type, not a value.
But if libstdc++7 is assuming that __has_builtin can be used to detect type
trait keywords, perhaps we should make it so; it's not unreasonable to
expect it to be usable for this purpose.

Would you be interested in providing a patch to Clang to implement this?

I have tested the code below with clang-5.0=5.0~svn307243-1 package from
> apt.llvm.org on a debian unstable box.
>
> #include <iostream>
>
> int main(void){
>         std::cout << "__has_builtin(__is_aggregate) = " <<
> __has_builtin(__is_aggregate) << std::endl;
>         std::cout << "__is_aggregate(int[42]) = " <<
> __is_aggregate(int[42]) << std::endl;
>         std::cout << "__is_aggregate(std::string) = " <<
> __is_aggregate(std::string) << std::endl;
>         return 0;
> }
>
> result:
> __has_builtin(__is_aggregate) = 0
> __is_aggregate(int[42]) = 1
> __is_aggregate(std::string) = 0
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170707/d480642a/attachment.html>


More information about the cfe-dev mailing list