[Bug 1052] demangle/abi_examples/{01,02}

[email protected]
Newsgroups gmane.linux.lsb.test-suite
Message-ID <[email protected]>


------- Additional Comments From [email protected]  2005-08-03 13:12 -------
The spec originally referred to the C++ ABI v1.75. However, the doc at
http://www.codesourcery.com/cxx-abi/abi.html is now 1.83.

This new doc says this about the demangler API:

 3.4 Demangler API

Synopsis:

namespace abi {
  extern "C" char* __cxa_demangle (const char* mangled_name,
				   char* buf,
				   size_t* n,
				   int* status);
}


    * mangled-name is a pointer to a null-terminated array of characters. It may
be either an external name, i.e. with a "_Z" prefix, or an internal NTBS
mangling, e.g. of a type for type_info.

    * buf may be null. If it is non-null, then n must also be nonnull, and buf
is a pointer to an array, of at least *n characters, that was allocated using
malloc.

    * status points to an int that is used as an error indicator. It is
permitted to be null, in which case the user just doesn't get any detailed error
information. 

Behavior: The return value is a pointer to a null-terminated array of
characters, the demangled name. Ambiguities are possible between extern "C"
object names and type manglings, e.g. "i" may be either an object named "i" or
the built-in "int" type. Such ambiguous arguments are assumed to be type
manglings. If the user has a set of external names to demangle, they should
check that the names are in fact mangled (that is, begin with "_Z") before
passing them to __cxa_demangle.

If there is an error in demangling, the return value is a null pointer. The user
can examine *status to find out what kind of error occurred. Meaning of error
indications:

    * 0: success
    * -1: memory allocation failure
    * -2: invalid mangled name
    * -3: invalid arguments (e.g. buf nonnull and n null) 

Memory management:

    * If buf is a null pointer, __cxa_demangle allocates a new buffer with
malloc. It stores the size of the buffer in *n, if n is not NULL.
    * If buf is not a null pointer, it must have been allocated with malloc. If
buf is not big enough to store the resulting demangled name, __cxa_demangle must
either a) call free to deallocate buf and then allocate a new buffer with
malloc, or b) call realloc to increase the size of the buffer. In either case,
the new buffer size will be stored in *n. 

-------------------------------------------

The old (1.75) spec was identical, except that the "Behavior" section read:
Behavior: The return value is a pointer to a null-terminated array of
characters, the demangled name. Ambiguities are possible between extern "C"
object names and internal built-in type names, e.g. "i" may be either an object
named "i" or the built-in "int" type. Such ambiguities should be resolved to
user names over built-in names.

--------------------------------------------
The diff here:
$ diff -u /tmp/cxx*
--- /tmp/cxx1.75        2005-08-03 10:05:47.000000000 -0700
+++ /tmp/cxx1.81        2005-08-03 10:05:38.000000000 -0700
@@ -18,9 +18,11 @@
  
 Behavior: The return value is a pointer to a null-terminated array of
 characters, the demangled name. Ambiguities are possible between extern
-"C" object names and internal built-in type names, e.g. "i" may be either
-an object named "i" or the built-in "int" type. Such ambiguities should
-be resolved to user names over built-in names.
+"C" object names and type manglings, e.g. "i" may be either an object
+named "i" or the built-in "int" type. Such ambiguous arguments are assumed
+to be type manglings. If the user has a set of external names to demangle,
+they should check that the names are in fact mangled (that is, begin with
+"_Z") before passing them to __cxa_demangle.
  
 If there is an error in demangling, the return value is a null pointer. The
user can examine *status to find out what kind of error occurred. Meaning of
error indications:
  
------------------------------------
This is the change that lead to the problem. We need to update the version
number of the ABI to 1.83 ... the PR should be an INT.

   
 
--    
Configure bugmail: http://bugs.linuxbase.org/userprefs.cgi?tab=email   
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.