C++ __使用devtoolset-4 gcc-5.2,rhel6(centos6)上的cxa_demangle出现故障

C++ __使用devtoolset-4 gcc-5.2,rhel6(centos6)上的cxa_demangle出现故障,c++,g++,libstdc++,rhel6,devtoolset,C++,G++,Libstdc++,Rhel6,Devtoolset,我尝试了一个最小的测试用例。该案例通过带有devtoolset-4(gcc-5.2)的rhel-7,并在rhel-6下失败。状态2表示“McDeLeNeNd”不是C++ ABI规则下的有效名称。 如果我想在RHEL-6上使用gcc-5.2,我是做错了还是要解决这个bug?若有,有何建议??到目前为止,我最好的想法是在把它交给uu cxa_demangle()之前,先将“IJ”这个扭曲的名字正则化为“II”。如果这可能是相对可靠的,我可以接受它 #include <iostream>

我尝试了一个最小的测试用例。该案例通过带有devtoolset-4(gcc-5.2)的rhel-7,并在rhel-6下失败。状态2表示“McDeLeNeNd”不是C++ ABI规则下的有效名称。 如果我想在RHEL-6上使用gcc-5.2,我是做错了还是要解决这个bug?若有,有何建议??到目前为止,我最好的想法是在把它交给uu cxa_demangle()之前,先将“IJ”这个扭曲的名字正则化为“II”。如果这可能是相对可靠的,我可以接受它

#include <iostream>
#include <string>
#include <tuple>
#include <typeinfo>
#include <cxxabi.h>

#define DUMP(x) std::cout << #x << " is " << x << std::endl

template<typename T>
void print_type(T t)
{
    int status;
    auto name = typeid(t).name();
    DUMP(name);
    auto thing2 = abi::__cxa_demangle(name, 0, 0, &status);
    if(status == 0)
    {
        DUMP(thing2);
    }
    else
    {
        std::cout << typeid(t).name() << " failed to demangle\n";
        DUMP(status);
    }
}

typedef std::tuple<foo_t, foo_t> b_t;

int main(int argc, char **argv)
{
    std::tuple<bool, bool> t;
    print_type(t);
}
Centos-7输出

name is St5tupleIJbbEE
thing2 is std::tuple<bool, bool>
名称是St5tupleIJbbEE
thing2是std::tuple
带有devtoolset-3(gcc-4.9)的Centos-6输出

名字是st5tupleibee
thing2是std::tuple
std::string typestring(typeid(T).name());
auto pos=typestring.find(“IJ”);
if(pos!=std::string::npos)
{
//gcc-5.2在typestring中使用IJ,其中
//gcc-4.9 used II-此fugly hack使
//使用gcc-5.2在centos/rhel-6上进行cxa_demangle工作
//例如std::tuple
typestring[pos+1]=“I”;
}
rv=abi::uuucxa_demangle(typestring.c_str()、0、0和status);

gcc 4和gcc 5之间没有ABI变化吗?我不是专家,但我记得我的同事谈论过这件事。
name is St5tupleIJbbEE
thing2 is std::tuple<bool, bool>
name is St5tupleIIbbEE
thing2 is std::tuple<bool, bool>
std::string typestring(typeid(T).name());
auto pos = typestring.find("IJ");
if(pos != std::string::npos)
{
    // gcc-5.2 uses IJ in typestring where
    // gcc-4.9 used II - this fugly hack makes
    // cxa_demangle work on centos/rhel-6 with gcc-5.2
    // eg std::tuple<bool, bool> 
    typestring[pos + 1] = 'I';
}
rv = abi::__cxa_demangle(typestring.c_str(), 0, 0, &status);