2012-08-19

clangとlibsupc++使うとvariadic template nameのマングル名が不正になる

なぜかよくわからないが、Ubuntu 12.04の環境で、clangとlibsupc++を使うと、Variadic template nameのmangled nameが不正になる。

// Ubuntu 12.04, libstdc++ and libsupc++

#include <cstdlib>
#include <iostream>
#include <typeinfo>
#include <cxxabi.h>

template < typename ... pack >
struct test { } ;

int main()
{
    // gcc prints 4testIIiEE
    // clang prints 4testIJiEE
    std::cout << typeid( test<int> ).name() << std::endl ;

    int status = 0 ;
    char * realname = abi::__cxa_demangle( typeid( test<int> ).name(), 0, 0, &status) ;
    std::free(realname) ;
    // in clang, status is -2(invalid mangled name)
    std::cout << status << std::endl ;
}

誰か確認できるだろうか。

No comments:

Post a Comment

You can use some HTML elements, such as <b>, <i>, <a>, also, some characters need to be entity referenced such as <, > and & Your comment may need to be confirmed by blog author. Your comment will be published under GFDL 1.3 or later license with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.