Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Clang++ compilation error #1915

Closed
wingfiring opened this issue Aug 7, 2023 · 2 comments
Closed

[Bug]: Clang++ compilation error #1915

wingfiring opened this issue Aug 7, 2023 · 2 comments
Labels

Comments

@wingfiring
Copy link

Description

Failed to build the following code (works with clang++ on other platforms)

#include <tuple>
#include <type_traits>

struct Foo{
    int v = 42;
    template<typename T> Foo& operator=(T ) 
        noexcept(std::is_nothrow_move_assignable<T>::value) {
        return *this;
    }
};

int main(){
    std::tuple<Foo> a, b;
    std::swap(a, b);
}

Save the above code to file a.cpp.
With command line:

~/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ -std=c++17 a.cpp --target=aarch64-none-linux-android28 --sysroot=$HOME/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/sysroot  -ftemplate-back
trace-limit=0 

Got error messages (modified to hide sensitive info):

In file included from a.cpp:1:
In file included from /Users/someone/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/c++/v1/tuple:149:
In file included from /Users/someone/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/c++/v1/__tuple:15:
/Users/someone/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/c++/v1/type_traits:3493:71: error: exception specification of 'operator=<std::__tuple_leaf<0, Foo, false>>' uses itself
    : public integral_constant<bool, __is_nothrow_assignable(_Tp, _Arg)> {};
                                                                      ^
/Users/someone/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/c++/v1/type_traits:3493:71: note: in instantiation of exception specification for 'operator=<std::__tuple_leaf<0, Foo, false>>' requested here
/Users/someone/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/c++/v1/type_traits:3540:14: note: in instantiation of template class 'std::is_nothrow_assignable<std::__tuple_leaf<0, Foo, false> &, std::__tuple_leaf<0, Foo, false> &&>' requested here
    : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
             ^
a.cpp:9:59: note: in instantiation of template class 'std::is_nothrow_move_assignable<std::__tuple_leaf<0, Foo, false>>' requested here
    template<typename T> Foo& operator=(T ) noexcept(std::is_nothrow_move_assignable<T>::value)
                                                          ^
/Users/someone/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/c++/v1/type_traits:3493:71: note: in instantiation of exception specification for 'operator=<std::__tuple_leaf<0, Foo, false>>' requested here
    : public integral_constant<bool, __is_nothrow_assignable(_Tp, _Arg)> {};
                                                                      ^
/Users/someone/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/c++/v1/tuple:263:42: note: in instantiation of template class 'std::is_nothrow_assignable<Foo &, std::__tuple_leaf<0, Foo, false>>' requested here
        operator=(_Tp&& __t) _NOEXCEPT_((is_nothrow_assignable<_Hp&, _Tp>::value))
                                         ^
/Users/someone/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/c++/v1/type_traits:2447:83: note: in instantiation of exception specification for 'operator=<std::__tuple_leaf<0, Foo, false>>' requested here
struct _LIBCPP_TEMPLATE_VIS is_assignable : _BoolConstant<__is_assignable(_Tp, _Up)> { };
                                                                                  ^
/Users/someone/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/c++/v1/type_traits:2501:14: note: in instantiation of template class 'std::is_assignable<std::__tuple_leaf<0, Foo, false> &, std::__tuple_leaf<0, Foo, false> &&>' requested here
    : public is_assignable<typename add_lvalue_reference<_Tp>::type,
             ^
/Users/someone/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/c++/v1/type_traits:4041:5: note: in instantiation of template class 'std::is_move_assignable<std::__tuple_leaf<0, Foo, false>>' requested here
    is_move_assignable<_Tp>::value
    ^
/Users/someone/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/c++/v1/type_traits:4099:21: note: while substituting deduced template arguments into function template 'swap' [with _Tp = std::__tuple_leaf<0, Foo, false>]
    static decltype(swap(_VSTD::declval<_LHS>(), _VSTD::declval<_RHS>()))
                    ^
/Users/someone/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/c++/v1/type_traits:4105:23: note: while substituting explicitly-specified template arguments into function template '__test_swap'
    typedef decltype((__test_swap<_Tp, _Up>(0))) __swap1;
                      ^
/Users/someone/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/c++/v1/type_traits:4115:57: note: in instantiation of template class 'std::__detail::__swappable_with<std::__tuple_leaf<0, Foo, false> &, std::__tuple_leaf<0, Foo, false> &, true>' requested here
template <class _Tp, class _Up = _Tp, bool _Swappable = __swappable_with<_Tp, _Up>::value>
                                                        ^
/Users/someone/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/c++/v1/type_traits:4139:48: note: in instantiation of default argument for '__nothrow_swappable_with<std::__tuple_leaf<0, Foo, false> &, std::__tuple_leaf<0, Foo, false> &>' required here
    : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp&>::value>
                                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/someone/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/c++/v1/tuple:270:44: note: in instantiation of template class 'std::__is_nothrow_swappable<std::__tuple_leaf<0, Foo, false>>' requested here
    int swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
                                           ^
/Users/someone/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/c++/v1/tuple:470:45: note: in instantiation of exception specification for 'swap' requested here
        __swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t))...);
                                            ^
/Users/someone/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/c++/v1/tuple:954:18: note: in instantiation of member function 'std::__tuple_impl<std::__tuple_indices<0>, Foo>::swap' requested here
        {__base_.swap(__t.__base_);}
                 ^
/Users/someone/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/c++/v1/tuple:1001:10: note: in instantiation of member function 'std::tuple<Foo>::swap' requested here
    {__t.swap(__u);}
         ^
a.cpp:19:10: note: in instantiation of function template specialization 'std::swap<Foo>' requested here
    std::swap(a, b);
         ^
1 error generated.

Upstream bug

No response

Commit to cherry-pick

No response

Affected versions

r25

Canary version

No response

Host OS

Mac

Host OS version

MacOS 12.6.7

Affected ABIs

arm64-v8a

@wingfiring wingfiring added the bug label Aug 7, 2023
@DanAlbert
Copy link
Member

This definitely looks like #1530. Test case compiles fine with r26 beta 1.

I did have to remove the -ftemplate-back argument which is not recognized. I also removed the sysroot argument which at best does nothing.

@wingfiring
Copy link
Author

yes, just verified in r26 beta 1, it's fixed.
Thanks for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants