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

            Bug ID: 117508
           Summary: [12/13/14/15 Regression] Weird debug location info for
                    C++ std::initializer_list
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

#include <string>

struct X {
  X(std::initializer_list<std::string>) { }
};

void test01() {
  X x { "E", "E", "T", "T" };
  return;
}

int main() {
  test01();
  return 0;
}

With GCC 11 debugging this works as expected, but since GCC 12.1 stepping into
test01 jumps around while constructing the initializer_list:

$ gdb -q  -ex start -ex step -ex n -ex n -ex n -ex cont -ex q ./a.out
Reading symbols from ./a.out...
Temporary breakpoint 1 at 0x4023b2: file 83709.cc, line 13.
Starting program: /tmp/a.out 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

Temporary breakpoint 1, main () at 83709.cc:13
13        test01();
test01 () at 83709.cc:10
10      }
8         X x { "E", "E", "T", "T" };
10      }
9         return;
Continuing.
[Inferior 1 (process 830655) exited normally]

We start on line 13 but after stepping into test01 we're on line 10 (the
closing brace of test01), then "next" takes us to line 8 where the
initializer_list is used, then "next" takes us back to line 10, then to line 9.

With GCC 11 it's great:

Temporary breakpoint 1, main () at 83709.cc:13
13        test01();
test01 () at 83709.cc:8
8         X x { "E", "E", "T", "T" };
9         return;
10      }
main () at 83709.cc:14
14        return 0;
Continuing.
[Inferior 1 (process 830849) exited normally]

Reply via email to