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

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I'm also seeing similar jumps back and forth in the debugger for the bodies of
lambda expressions, where the debugger keeps jumping back to the capture list
of the lambda:


$ cat lambda.cc 
int main(int argc, char**)
{
  int x = 1;
  auto f = [&x, &argc](const char* i) {
    i += x;
    i -= argc;
    i += argc - x;
    return i;
  };
  f("          ");
}
$ g++ -g lambda.cc -o lambda
$ gdb -q -ex start -ex 'py [gdb.execute("step") for n in range(14)]' ./lambda
Reading symbols from ./lambda...
Temporary breakpoint 1 at 0x40117a: file lambda.cc, line 3.
Starting program: /tmp/lambda 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

Temporary breakpoint 1, main (argc=1) at lambda.cc:3
3         int x = 1;
9         };
10        f("          ");
operator() (__closure=0x7fffffffda60, i=0x402004 "          ") at lambda.cc:5
5           i += x;
4         auto f = [&x, &argc](const char* i) {
5           i += x;
6           i -= argc;
4         auto f = [&x, &argc](const char* i) {
6           i -= argc;
7           i += argc - x;
4         auto f = [&x, &argc](const char* i) {
7           i += argc - x;
4         auto f = [&x, &argc](const char* i) {
7           i += argc - x;
8           return i;

We keep returning to line 4 (the capture) every time the captured variiable is
odr-used.

Reply via email to