clang fails to compile gcc 4.8's <unordered_map>

Hello,

Clang fails to compile GCC 4.8.0's <unordered_map> with the following errors:

gcc-4.8/include/c++/4.8.0/bits/hashtable_policy.h:806:8: error: expected unqualified-id
using __is_convertible = std::is_convertible<_Pair, value_type>;
^
gcc-4.8/include/c++/4.8.0/bits/hashtable_policy.h:809:49: error: expected '('
using _IFconv = std::enable_if<__is_convertible<_Pair>::value>;
^
gcc-4.8/include/c++/4.8.0/bits/hashtable_policy.h:809:50: error: '_Pair' does not refer to a value
using _IFconv = std::enable_if<__is_convertible<_Pair>::value>;
^
gcc-4.8/include/c++/4.8.0/bits/hashtable_policy.h:808:25: note: declared here
template<typename _Pair>
^
gcc-4.8/include/c++/4.8.0/bits/hashtable_policy.h:809:58: error: expected ';' after alias declaration
using _IFconv = std::enable_if<__is_convertible<_Pair>::value>;
^
gcc-4.8/include/c++/4.8.0/bits/hashtable_policy.h:812:28: error: expected a qualified name after
'typename'
using _IFconvp = typename _IFconv<_Pair>::type;
^
gcc-4.8/include/c++/4.8.0/bits/hashtable_policy.h:812:27: error: expected ';' after alias declaration
using _IFconvp = typename _IFconv<_Pair>::type;
^
gcc-4.8/include/c++/4.8.0/bits/hashtable_policy.h:814:43: error: unknown type name '_IFconvp'
template<typename _Pair, typename = _IFconvp<_Pair>>
^
gcc-4.8/include/c++/4.8.0/bits/hashtable_policy.h:814:51: error: expected ',' or '>' in
template-parameter-list
template<typename _Pair, typename = _IFconvp<_Pair>>
^
gcc-4.8/include/c++/4.8.0/bits/hashtable_policy.h:814:58: error: expected member name or ';' after
declaration specifiers
template<typename _Pair, typename = _IFconvp<_Pair>>
^

The problem is that GCC uses the following alias template as class scope:

template<typename _Pair>
using __is_convertible = std::is_convertible<_Pair, value_type>;

but __is_convertible, I am guessing, is a compiler intrinsic in clang.

Is either gcc or clang doing something wrong, or is it just a clash of implementations?
What can be done to resolve this?

Thanks,
Nate

The problem is that GCC uses the following alias template as class scope:

template<typename _Pair>
using __is_convertible = std::is_convertible<_Pair, value_type>;

but __is_convertible, I am guessing, is a compiler intrinsic in clang.

Is either gcc or clang doing something wrong, or is it just a clash of implementations?

It's a clash of implementations. We've had this before, but not with a new GCC version - only with old GCC versions.

What can be done to resolve this?

Since GCC 4.8 is not yet released, and Clang versions with the __is_convertible intrinsic are, the best solution would be to politely ask the libstdc++ maintainers to change this name.

Sebastian

Please let us know if you do / what the PR is for it? We’re likely to hit this as well, and will want to track the progress of getting it resolved.

This looks fixable on the clang side to me. The clang intrinsic __is_convertible is currently undocumented:

http://clang.llvm.org/docs/LanguageExtensions.html#checking_type_traits

However we document __is_convertible_to

int main()
{
    static_assert(__is_convertible(int, long), "");
    static_assert(__is_convertible_to(int, long), "");
}

I imagine __is_convertible was left in to give time for things like libc++ to migrate to __is_convertible_to. It has. Why don't we just dump __is_convertible.

Howard

We can certainly do this (and probably should) but it doesn’t fix released versions of Clang… so my preference would be to still change libstdc++ prior to the next GCC release in order to have as much inter-version/toolchain compatibility as we can.

Date: Thu, 31 May 2012 02:18:56 -0700
From: chandlerc@google.com
To: sebastian.redl@getdesigned.at
CC: cfe-dev@cs.uiuc.edu
Subject: Re: [cfe-dev] clang fails to compile gcc 4.8's <unordered_map>

> The problem is that GCC uses the following alias template as class scope:
>
> template<typename _Pair>
> using __is_convertible = std::is_convertible<_Pair, value_type>;
>
> but __is_convertible, I am guessing, is a compiler intrinsic in clang.
>
> Is either gcc or clang doing something wrong, or is it just a clash
of implementations?
It's a clash of implementations. We've had this before, but not with a
new GCC version - only with old GCC versions.
> What can be done to resolve this?
>
Since GCC 4.8 is not yet released, and Clang versions with the
__is_convertible intrinsic are, the best solution would be to politely
ask the libstdc++ maintainers to change this name.

Please let us know if you do / what the PR is for it? We're likely to
hit this as well, and will want to track the progress of getting it
resolved.

I filed 53543 – [unordered_map] conflict with __is_convertible clang intrinsic

Regards,
Nate