Bug 22411 - cp-name-parser.y doesn't grok templates with function type as template argument
Summary: cp-name-parser.y doesn't grok templates with function type as template argument
Status: RESOLVED DUPLICATE of bug 11907
Alias: None
Product: gdb
Classification: Unclassified
Component: c++ (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-11-08 16:01 UTC by Pedro Alves
Modified: 2024-04-20 16:44 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Pedro Alves 2017-11-08 16:01:22 UTC
I noticed that gdb/cp-name-parser.y:cp_demangled_name_to_comp fails to grok this:

  "A::foo<void (int)>::func(int)"

which is a valid symbol name that can result from something like this:

~~~
#include <stdio.h>

namespace A
{
  template<typename T>
  struct foo
  {
    void func (int)
    {
      printf ("hello");
    }
  };
}

A::foo<void(int)> f1; // bad cases instantiated from this one here
A::foo<int> f2;

int
main (int argc, char **argv)
{
  f1.func (argc);
  f2.func (argc);

  return 0;
}
~~~

$ nm a.out | c++filt | grep func
000000000040062a W A::foo<void (int)>::func(int)
000000000040064c W A::foo<int>::func(int)

Running the symbol through test-cp-name-parser, we see:

 $ ./test-cp-name-parser 'A::foo<void (int)>::func(int)'
 syntax error, near `int)>::func(int)'

While the non-function-type one works OK:

 $ ./test-cp-name-parser 'A::foo<int>::func(int)'
 A::foo<int>::func(int)

A smaller reproducer:

 $ ./test-cp-name-parser 'foo<void(void)>'
 syntax error, near `void)>'

Function pointer types work OK:

 $ ./test-cp-name-parser 'foo<void (*) (void)>'
Comment 1 Tom Tromey 2024-04-20 16:44:51 UTC
Dup.

*** This bug has been marked as a duplicate of bug 11907 ***