This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: analysis of libiberty/cp-demangle.c for libsupc++/__cxa_demangle
- From: Ian Lance Taylor <ian at wasabisystems dot com>
- To: Benjamin Kosnik <bkoz at redhat dot com>
- Cc: mark at codesourcery dot com, libstdc++ at gcc dot gnu dot org
- Date: 25 Feb 2004 00:01:51 -0500
- Subject: Re: analysis of libiberty/cp-demangle.c for libsupc++/__cxa_demangle
- References: <20040223170416.7a0ab854.bkoz@redhat.com>
Benjamin Kosnik <bkoz@redhat.com> writes:
> I have 4 new fails when it's used.
>
> FAIL: demangle/abi_examples/01.cc execution test
> FAIL: demangle/abi_examples/02.cc execution test
> string: f
> libiberty: float
> libstdc++: f
>
> I think libiberty is pretty clearly wrong here, just based on the C++ ABI docs.
I have fixed the libiberty demangler so that it returns an error
status of -2 for this case. The libstdc++-v3 test case will still
fail, but, as discussed, I think it is defensible to change the tests
to:
verify_demangle("f", "error code = -2: invalid mangled name");
> FAIL: demangle/regression/cw-11.cc execution test
> string: _X11TransParseAddress
> libiberty: _X11TransParseAddress, -2: invalid mangled name
> libstdc++: _X11TransParseAddress
>
> Same: this is twisted, but not invalid.
As discussed, I think the libiberty demangler is behaving correctly
here.
> FAIL: demangle/regression/cw-16.cc execution test
> string: _Z3fooIA6_KiEvA9_KT_rVPrS4_
> libiberty:void foo<int const [6]>(int const ( const [9]) [6], int const ( const ( restrict* volatile restrict) [9]) [6])
> libstdc++:void foo<int const [6]>(int const [9][6], int const restrict (* volatile restrict) [9][6])
>
> This is based on libstdc++/12736.
> See http://gcc.gnu.org/ml/libstdc++/2003-10/msg00222.html
I have fixed this bug. The output is now the same as the libstdc++-v3
demangler, except that the libiberty demangler prints "restrict const"
instead of "const restrict".
With the libiberty demangler which is currently on mainline, and
Benjamin's patch to use it in libstdc++-v3, the appended patches
permit the libstdc++-v3 testsuite to run with no demangling errors.
Besides the cases discussed above, there is a difference where the
libstdc++-v3 demangler prints [extern "C"] and the libiberty demangler
prints nothing. Historically the libiberty demangler has only printed
[extern "C"] when in verbose mode. In fact, the current libiberty
demangler never prints it. I don't personally consider this to be
particularly serious; I think the testcase below shows that the
notation is relatively useless.
Ian
Index: demangle/abi_examples/01.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/demangle/abi_examples/01.cc,v
retrieving revision 1.2
diff -p -u -r1.2 01.cc
--- demangle/abi_examples/01.cc 24 Jul 2003 21:08:01 -0000 1.2
+++ demangle/abi_examples/01.cc 25 Feb 2004 04:59:27 -0000
@@ -31,7 +31,7 @@ int main()
// extern "C" function
// extern "C" float f(void) { };
// T f
- verify_demangle("f", "f");
+ verify_demangle("f", "error code = -2: invalid mangled name");
return 0;
}
Index: demangle/abi_examples/02.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/demangle/abi_examples/02.cc,v
retrieving revision 1.2
diff -p -u -r1.2 02.cc
--- demangle/abi_examples/02.cc 24 Jul 2003 21:08:01 -0000 1.2
+++ demangle/abi_examples/02.cc 25 Feb 2004 04:59:28 -0000
@@ -31,7 +31,7 @@ int main()
// or variable "f"
// int f;
// B f
- verify_demangle("f", "f");
+ verify_demangle("f", "error code = -2: invalid mangled name");
return 0;
}
Index: demangle/regression/cw-11.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/demangle/regression/cw-11.cc,v
retrieving revision 1.2
diff -p -u -r1.2 cw-11.cc
--- demangle/regression/cw-11.cc 24 Jul 2003 21:08:02 -0000 1.2
+++ demangle/regression/cw-11.cc 25 Feb 2004 04:59:28 -0000
@@ -28,7 +28,8 @@ int main()
using namespace __gnu_test;
// cplus-dem CORE
- verify_demangle("_X11TransParseAddress", "_X11TransParseAddress");
+ verify_demangle("_X11TransParseAddress",
+ "error code = -2: invalid mangled name");
return 0;
}
Index: demangle/regression/cw-16.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/demangle/regression/cw-16.cc,v
retrieving revision 1.4
diff -p -u -r1.4 cw-16.cc
--- demangle/regression/cw-16.cc 5 Dec 2003 02:40:53 -0000 1.4
+++ demangle/regression/cw-16.cc 25 Feb 2004 04:59:28 -0000
@@ -29,14 +29,14 @@ int main()
// 2003/11/07, libstdc++/12736
verify_demangle("_Z3fooIA6_KiEvA9_KT_rVPrS4_",
- "void foo<int const [6]>(int const [9][6], int const restrict (* volatile restrict) [9][6])");
+ "void foo<int const [6]>(int const [9][6], int restrict const (* volatile restrict) [9][6])");
// 2003/11/12, libstdc++/12947
verify_demangle("_Z1fILi5E1AEvN1CIXqugtT_Li0ELi1ELi2EEE1qE",
"void f<5, A>(C<(((5) > (0))) ? (1) : (2)>::q)");
verify_demangle("_Z1fILi5EEvN1AIXcvimlT_Li22EEE1qE",
"void f<5>(A<(int)((5) * (22))>::q)");
verify_demangle("_Z1fPFYPFiiEiE",
- "f(int (*(*) [extern \"C\"] (int))(int))");
+ "f(int (*(*)(int))(int))");
verify_demangle("_Z1fI1XENT_1tES2_",
"X::t f<X>(X::t)");
verify_demangle("_Z1fILi5E1AEvN1CIXstN1T1tEEXszsrS2_1tEE1qE",