From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2834 invoked by alias); 22 Apr 2017 23:06:13 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 2822 invoked by uid 89); 22 Apr 2017 23:06:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy=H*Ad:U*richard, H*r:sk:gdb@sou, demonstrate, forth X-HELO: szibele.com Received: from szibele.com (HELO szibele.com) (130.255.78.218) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 22 Apr 2017 23:06:11 +0000 Received: from [192.168.178.28] (p50864CCC.dip0.t-ipconnect.de [80.134.76.204]) by szibele.com (Postfix) with ESMTPSA id 8C0BF6969A for ; Sun, 23 Apr 2017 01:06:11 +0200 (CEST) To: gdb@sourceware.org From: Richard Szibele Subject: GDB 7.12.1: Strange "stepping" behavior Message-ID: Date: Sat, 22 Apr 2017 23:06:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2017-04/txt/msg00031.txt.bz2 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 #include int main() { auto ptr = std::shared_ptr(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