https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123988

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
It's the other way around, the first one fails and the second (shorter) one
works.

The __cxa_demangle function returns -2 meaning:

-2: MANGLED_NAME is not a valid name under the C++ ABI mangling rules.

What actually happens is we hit this case:

  /* PR 87675 - Check for a mangled string that is so long
     that we do not have enough stack space to demangle it.  */
  if (((options & DMGL_NO_RECURSE_LIMIT) == 0)
      /* This check is a bit arbitrary, since what we really want to do is to
         compare the sizes of the di.comps and di.subs arrays against the
         amount of stack space remaining.  But there is no portable way to do
         this, so instead we use the recursion limit as a guide to the maximum
         size of the arrays.  */
      && (unsigned long) di.num_comps > DEMANGLE_RECURSION_LIMIT)
    {
      /* FIXME: We need a way to indicate that a stack limit has been reached. 
*/
      return 0;
    }

The limit is defined in include/demangle.h

/* If DMGL_NO_RECURSE_LIMIT is not enabled, then this is the value used as
   the maximum depth of recursion allowed.  It should be enough for any
   real-world mangled name.  */
#define DEMANGLE_RECURSION_LIMIT 2048

Reply via email to