This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
GDB 7.12.1: Strange "stepping" behavior
- From: Richard Szibele <richard at szibele dot com>
- To: gdb at sourceware dot org
- Date: Sun, 23 Apr 2017 01:06:11 +0200
- Subject: GDB 7.12.1: Strange "stepping" behavior
- Authentication-results: sourceware.org; auth=none
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