clang++: std::is_aggregate unusable with clang-5.0/libstdc++-7

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

clang++: std::is_aggregate unusable with clang-5.0/libstdc++-7

Adam Cieszkiel via cfe-dev
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++.

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
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: clang++: std::is_aggregate unusable with clang-5.0/libstdc++-7

Adam Cieszkiel via cfe-dev
On 07/07/2017 03:23 AM, Katsuhiko Nishimra via cfe-dev 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++.
>

Is this a regression?  Also, can you file a bug at bugs.llvm.org and
add me as a cc: [hidden email].

Thanks,
Tom

> 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
> [hidden email]
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: clang++: std::is_aggregate unusable with clang-5.0/libstdc++-7

Adam Cieszkiel via cfe-dev
In reply to this post by Adam Cieszkiel via cfe-dev
On 7 July 2017 at 00:23, Katsuhiko Nishimra via cfe-dev <[hidden email]> 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
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev



_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: clang++: std::is_aggregate unusable with clang-5.0/libstdc++-7

Adam Cieszkiel via cfe-dev
On Fri, Jul 07, 2017 at 12:50:24PM -0700, Richard Smith wrote:
> __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.

I see. Sorry to have misunderstood.
>
> Would you be interested in providing a patch to Clang to implement this?

I don't know much about Clang's codebase, so I think it's better to send
one to libstdc++. But how can I detect if __is_aggregate macro is
usable? I've tried #ifdef directive but with no luck.
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: clang++: std::is_aggregate unusable with clang-5.0/libstdc++-7

Adam Cieszkiel via cfe-dev
On 8 July 2017 at 06:16, Katsuhiko Nishimra <[hidden email]> wrote:
On Fri, Jul 07, 2017 at 12:50:24PM -0700, Richard Smith wrote:
> __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.

I see. Sorry to have misunderstood.
>
> Would you be interested in providing a patch to Clang to implement this?

I don't know much about Clang's codebase, so I think it's better to send
one to libstdc++. But how can I detect if __is_aggregate macro is
usable? I've tried #ifdef directive but with no luck.

I think !__is_identifier(__is_aggregate) is the only way we have to detect this right now.

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: clang++: std::is_aggregate unusable with clang-5.0/libstdc++-7

Adam Cieszkiel via cfe-dev
I've passed this information Jonathan Wakely so that he can correct it.

/Eric

On Tue, Jul 11, 2017 at 7:02 AM, Richard Smith via cfe-dev <[hidden email]> wrote:
On 8 July 2017 at 06:16, Katsuhiko Nishimra <[hidden email]> wrote:
On Fri, Jul 07, 2017 at 12:50:24PM -0700, Richard Smith wrote:
> __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.

I see. Sorry to have misunderstood.
>
> Would you be interested in providing a patch to Clang to implement this?

I don't know much about Clang's codebase, so I think it's better to send
one to libstdc++. But how can I detect if __is_aggregate macro is
usable? I've tried #ifdef directive but with no luck.

I think !__is_identifier(__is_aggregate) is the only way we have to detect this right now.

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev



_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Loading...