This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GDB 7.12.1: Strange "stepping" behavior


Hello everyone,

I am experiencing strange stepping behavior with GDB 7.12.1 and a program compiled with g++ (GCC) 5.4.0 which I can demonstrate with a simple example:


#include <memory>
#include <iostream>

int main()
{
    auto ptr = std::shared_ptr<int>(new int);
    *ptr = 100;
    std::cout << *ptr << std::endl;
    return 0;
}


I've compiled the above with the following g++ flags:

g++ -std=c++14 -g -O0 main.cpp

and then run gdb on the resulting executable.

When I step over using "next" I end up jumping back and forth, rather than a simple linear top-down progression in the source code. I've read that this is due to compiler optimizations, but as I've supplied the flags -g and -O0, I do not believe this should happen.

Is this a bug or am I doing something wrong?

Best Regards,
Richard Szibele


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]