This test program produces different results for 3.3.2 and 3.4. cat > test.c <<EOF #include <stdio.h> #include <stdlib.h> extern char *__cxa_demangle (const char *__mangled_name, char *__output_buffer, __SIZE_TYPE__ *__length, int *__status); int main(int argc, char** argv) { for (int i=1;i<argc;++i) { int status; char* res = __cxa_demangle(argv[i],0,0,&status); if (res!=NULL || status!=0) { printf("Demangled '%s' as '%s'\n",argv[i],res); } else { printf("Could not demangle '%s'\n",argv[i]); } free(res); } return 0; } EOF /local/gcc/bin/gcc -o test test.c -std=c99 /local/gcc/lib/libstdc++.a './test hello' produces Demangled 'hello' as 'unsigned char' Also, if I don't pass the status flag pointer, then I get Could not demangle 'hello' Code is working in mainline, but it would be nice to have it work in 3.3 release series as well. Can this be backported?
The demangler in 3.4 is a complete rewrite, it cannot be back ported. What needs to be fixed here is that the __cxa_demangle implementation in 3.3 1) Doesn't take the string length of the input into account (ie, it demangles what it can and ignores any trailing characters). It should fail if any characters are trailing. 2) A single character should NOT be considered to be a mangled type name (a builtin-type) - but returned as-is. Instead, it demangles the 'h' and ignores the rest. I am afraid I have no time to write patches for the 3.3 branch, but I am sure this would be a small patch.
The 3.3.x __cxa_demangle code is considered broken. It's been re-written a couple of times now.