我正在尝试使用 Clang 和 Fedora 上的默认 C++ 标准库(4.6.2)编译一个小型 C++ 程序。Clang 本身可以编译,并且仅使用的测试程序可以编译并运行良好。
我的另一个程序使用了 clang 抱怨的绳索。
/usr/lib/gcc/x86_64-redhat-linux/4.6.2/../../../../include/c++/4.6.2/ext/ropeimpl.h:433:2:错误:使用未声明的标识符 '_Data_allocate' _Data_allocate(_S_rounded_up_size(__old_len + __len));
针对此错误消息已针对 clang 提交了一个错误,并且解决方案是 clang 是正确的,库代码无效。
Clang在这里是正确的。对 _Data_allocate 的调用中没有与类型相关的参数,因此名称查找在模板定义时失败。
失败代码的上下文:
// Concatenate a C string onto a leaf rope by copying the rope data.
// Used for short ropes.
template <class _CharT, class _Alloc>
typename rope<_CharT, _Alloc>::_RopeLeaf*
rope<_CharT, _Alloc>::
_S_leaf_concat_char_iter(_RopeLeaf* __r, const _CharT* __iter, size_t __len)
{
size_t __old_len = __r->_M_size;
_CharT* __new_data = (_CharT*)
_Data_allocate(_S_rounded_up_size(__old_len + __len));
_RopeLeaf* __result;
uninitialized_copy_n(__r->_M_data, __old_len, __new_data);
uninitialized_copy_n(__iter, __len, __new_data + __old_len);
_S_cond_store_eos(__new_data[__old_len + __len]);
__try
{
__result = _S_new_RopeLeaf(__new_data, __old_len + __len,
__r->_M_get_allocator());
}
__catch(...)
{
_RopeRep::__STL_FREE_STRING(__new_data, __old_len + __len,
__r->_M_get_allocator());
__throw_exception_again;
}
return __result;
}
我的问题是,如果此代码无效,是否有简单的解决方法?g++ 编译这个没问题。