PATCH: PR other/42230: abi::__cxa_demangle fails to return the length of the decoded name

H.J. Lu hongjiu.lu@intel.com
Sat Jan 9 21:53:00 GMT 2010


Hi,

I am testing this patch to return length according as documented. OK
if no regressions?

Thanks.


H.J.
---
libiberty/

2010-01-09  Ian Lance Taylor  <iant@google.com>

	PR other/42230
	* cp-demangle.c (d_demangle): Return dgs.alc on success.

libstdc++-v3/

2010-01-09  H.J. Lu  <hongjiu.lu@intel.com>

	PR other/42230
	* testsuite/abi/pr42230.cc: New.

diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c
index 43cf34a..d37c90e 100644
--- a/libiberty/cp-demangle.c
+++ b/libiberty/cp-demangle.c
@@ -4777,7 +4777,7 @@ d_demangle (const char *mangled, int options, size_t *palc)
       return NULL;
     }
 
-  *palc = dgs.allocation_failure ? 1 : 0;
+  *palc = dgs.allocation_failure ? 1 : dgs.alc;
   return dgs.buf;
 }
 
--- /dev/null	2010-01-07 11:41:26.231386042 -0800
+++ a/libstdc++-v3/testsuite/abi/pr42230.cc	2010-01-09 13:44:12.000000000 -0800
@@ -0,0 +1,16 @@
+// { dg-do run }
+
+#include <cxxabi.h>
+#include <cassert>
+#include <cstddef>
+
+int main()
+{
+  std::size_t length = 0;
+  int cc;
+
+  char* ret = abi::__cxa_demangle("e", 0, &length, &cc);
+
+  assert( (cc < 0 && !ret) || (ret && length) );
+  return 0;
+}



More information about the Gcc-patches mailing list