[Bug demangler/96143] New: C++ demangler should not add a lambda as a substitution

ian at airs dot com gcc-bugzilla@gcc.gnu.org
Fri Jul 10 04:27:30 GMT 2020


            Bug ID: 96143
           Summary: C++ demangler should not add a lambda as a
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: demangler
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ian at airs dot com
  Target Milestone: ---

The C++ demangler adds a lambda as a substitution in d_lambda in
libiberty/cp-demangle.c.  However, the C++ compiler does not add a lambda as a
substitution in write_closure_type_name in cp/mangle.c.  According to
https://codesourcery.com/cxx-abi, the compiler is correct and the demangler is

Here is a test case that shows the problem:

template<typename F>
struct A {
  typedef int X;

template<typename F>
inline typename A<F>::X
F2(F f) {
  return 0;

void F() {

This produces the symbol _Z2F2IZ1FvEUlvE_EN1AIT_E1XES2_, which is the type of
F2 instantiated with a lambda.  Currently the demangler demangles this as

A<F()::{lambda()#1}>::X F2<F()::{lambda()#1}>(A)

Note the final (A).  That does not make sense.  The argument type of F2 is not
A, which doesn't even make sense by itself.  The argument type is a lambda.

Compare to the output of llvm-cxxfilt:

A<F()::'lambda'()>::X F2<F()::'lambda'()>(F()::'lambda'())

Here the argument is correctly shown as a lambda.

I can send a patch.

More information about the Gcc-bugs mailing list