【问题标题】:gnustl (libstdc++) to llvm (libc++ ) errorsgnustl (libstdc++) 到 llvm (libc++) 错误
【发布时间】:2019-01-04 05:19:24
【问题描述】:

从 gnustl 迁移到 libc++ 后,我开始遇到这些错误。我在互联网上找不到任何东西。并且没有更多信息。 我正在继续对此进行调查,随着调查的进行,我将用我的发现更新此线程。

f:/nugetcache\androidndk.16.1.9\sources\cxx-stl\llvm-libc++\include\__tree(1819,22) :  error: the specified comparator type does not provide a const call operator [-Werror,-Wuser-defined-warnings]
                     __trigger_diagnostics()), "");
                     ^
f:/nugetcache\androidndk.16.1.9\sources\cxx-stl\llvm-libc++\include\set(400,28) :  note: in instantiation of member function 'std::__ndk1::__tree<IRichValue::Type, IRichValueUtil::TypeComparer, HeapAllocator<IRichValue::Type> >::~__tree' requested here
class _LIBCPP_TEMPLATE_VIS set
                           ^
f:/nugetcache\androidndk.16.1.9\sources\cxx-stl\llvm-libc++\include\memory(1550,14) :  note: in instantiation of function template specialization 'std::__ndk1::allocator_traits<HeapAllocator<std::__ndk1::__tree_node<std::__ndk1::__value_type<RichValueTypeReservedKeyInfoManager *, Set<IRichValue::Type, IRichValueUtil::TypeComparer, HeapAllocator<IRichValue::Type> > >, void *> > >::__destroy<std::__ndk1::pair<RichValueTypeReservedKeyInfoManager *const, Set<IRichValue::Type, IRichValueUtil::TypeComparer, HeapAllocator<IRichValue::Type> > > >' requested here
            {__destroy(__has_destroy<allocator_type, _Tp*>(), __a, __p);}
             ^
f:/nugetcache\androidndk.16.1.9\sources\cxx-stl\llvm-libc++\include\__tree(1833,24) :  note: in instantiation of function template specialization 'std::__ndk1::allocator_traits<HeapAllocator<std::__ndk1::__tree_node<std::__ndk1::__value_type<RichValueTypeReservedKeyInfoManager *, Set<IRichValue::Type, IRichValueUtil::TypeComparer, HeapAllocator<IRichValue::Type> > >, void *> > >::destroy<std::__ndk1::pair<RichValueTypeReservedKeyInfoManager *const, Set<IRichValue::Type, IRichValueUtil::TypeComparer, HeapAllocator<IRichValue::Type> > > >' requested here
        __node_traits::destroy(__na, _NodeTypes::__get_ptr(__nd->__value_));
                       ^
f:/nugetcache\androidndk.16.1.9\sources\cxx-stl\llvm-libc++\include\__tree(1821,3) :  note: in instantiation of member function 'std::__ndk1::__tree<std::__ndk1::__value_type<RichValueTypeReservedKeyInfoManager *, Set<IRichValue::Type, IRichValueUtil::TypeComparer, HeapAllocator<IRichValue::Type> > >, std::__ndk1::__map_value_compare<RichValueTypeReservedKeyInfoManager *, std::__ndk1::__value_type<RichValueTypeReservedKeyInfoManager *, Set<IRichValue::Type, IRichValueUtil::TypeComparer, HeapAllocator<IRichValue::Type> > >, std::__ndk1::less<RichValueTypeReservedKeyInfoManager *>, true>, HeapAllocator<std::__ndk1::__value_type<RichValueTypeReservedKeyInfoManager *, Set<IRichValue::Type, IRichValueUtil::TypeComparer, HeapAllocator<IRichValue::Type> > > > >::destroy' requested here
  destroy(__root());
  ^
f:/nugetcache\androidndk.16.1.9\sources\cxx-stl\llvm-libc++\include\map(805,28) :  note: in instantiation of member function 'std::__ndk1::__tree<std::__ndk1::__value_type<RichValueTypeReservedKeyInfoManager *, Set<IRichValue::Type, IRichValueUtil::TypeComparer, HeapAllocator<IRichValue::Type> > >, std::__ndk1::__map_value_compare<RichValueTypeReservedKeyInfoManager *, std::__ndk1::__value_type<RichValueTypeReservedKeyInfoManager *, Set<IRichValue::Type, IRichValueUtil::TypeComparer, HeapAllocator<IRichValue::Type> > >, std::__ndk1::less<RichValueTypeReservedKeyInfoManager *>, true>, HeapAllocator<std::__ndk1::__value_type<RichValueTypeReservedKeyInfoManager *, Set<IRichValue::Type, IRichValueUtil::TypeComparer, HeapAllocator<IRichValue::Type> > > > >::~__tree' requested here
class _LIBCPP_TEMPLATE_VIS map
                           ^
f:/nugetcache\androidndk.16.1.9\sources\cxx-stl\llvm-libc++\include\__tree(970,7) :  note: from 'diagnose_if' attribute on '__trigger_diagnostics':
      _LIBCPP_DIAGNOSE_WARNING(!__invokable<_Compare const&, _Tp const&, _Tp const&>::value,
      ^                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
f:/nugetcache\androidndk.16.1.9\sources\cxx-stl\llvm-libc++\include\__config(1101,20) :  note: expanded from macro '_LIBCPP_DIAGNOSE_WARNING'
    __attribute__((diagnose_if(__VA_ARGS__, "warning")))
                   ^           ~~~~~~~~~~~
1 error generated.
Exit code: 1

【问题讨论】:

    标签: android c++ libstdc++ libc++


    【解决方案1】:

    这告诉您,您正在将比较对象传递给具有非常量 operator () 的集合或映射。

    您可以修复比较运算符或关闭-Werror(这将使其成为警告而不是错误)

    如果我是你,我会看看std::__ndk1::less

    【讨论】:

    • 是的,使函数 const 解决了这个问题,但问题是它如何与 gnustl 一起工作。
    • libstdc++ 不会检测并警告比较函数为 const 的要求 - 许多集合操作将使用非 const op()。但有些不会:
    • 例如:如果 myLess 的 operator() 未标记为 const,const set&lt;int, myLess&lt;int&gt;&gt; s; s.find(0); 将无法编译并显示非常奇怪的错误消息。 libc++ 会为您诊断。
    • 你会在 GCC 8 (live example) 中得到一个非常相似的错误,但是旧版本没有费心去强制执行这个要求,所以一些设置操作可以工作,而有些则不行。现在,如果您的比较对象有问题,它总是会报错,就像 libc++ 一样。
    猜你喜欢
    • 2017-01-03
    • 1970-01-01
    • 2022-01-07
    • 2015-10-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-28
    • 1970-01-01
    相关资源
    最近更新 更多