I am playing with demangling and I noticed that for std::string the mangled name depends on the compiler in use. For example, this simple program:
#include <cxxabi.h>
#include <iostream>
#include <string>
int main(){
std::cout << typeid(std::string).name() << std::endl;
return 0;
}
compiled under CentOS 7 using g++ 7.3.1 (from devtoolset-7) with --std=c++14
returns:
Ss
while under Ubuntu 18.04 with g++ 7.5.0 with the same flag:
NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
I don't understand what determines the different behavior, since the two compiler versions are pretty similar. The only thing that comes to my mind is that maybe it could be due to different versions of libstdc++, but I can't figure out the underlying reason.
That's completely expected. typeid
names are implementation defined and are not required to be identical across different implementations or even between different versions of the same implementation (compiler). They are also not required to be equal to the mangled names.