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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jeff Garrett from comment #0)
> Note that both a1 and a2 are interpreted as holding type main::{lambda()#2},
> but a1 actually holds main::{lambda()#1}.

I can fix the regex to work for lambdas, but I'm not sure what to do about that
part.

The debuginfo for the manager just shows the type as "main()::<lambda()>" which
doesn't uniquely identify the type. The function's gdb.Symbol.linkage_name
property (which is supposed to be the mangled name) is the same as its
gdb.Symbol.name, so that doesn't help.

The problem isn't specific to lambdas, but to any local type:

#include <any>
int main()
{
  std::any a3, a4;

  {
    struct local { } l;
    a3 = l;
  }

  {
    struct local { int i = 2; } l2;
    a4 = l2;
  }

  __builtin_trap();
}

g++ -std=c++17 87308.cc && gdb -q -ex r -ex "p a3" -ex "p a4" -ex qq a.out
Reading symbols from a.out...done.
Starting program: /tmp/a.out 

Program received signal SIGILL, Illegal instruction.
main () at 87308.cc:16
16        __builtin_trap();
$1 = std::any containing local = {[contained value] = {i = 0}}
$2 = std::any containing local = {[contained value] = {i = 2}}

Reply via email to