From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31036 invoked by alias); 16 Jul 2014 06:05:00 -0000 Mailing-List: contact gdb-prs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-prs-owner@sourceware.org Received: (qmail 31009 invoked by uid 48); 16 Jul 2014 06:04:59 -0000 From: "gdb at dima dot secretsauce.net" To: gdb-prs@sourceware.org Subject: [Bug gdb/17161] New: gdb confused about variable address in a nested function Date: Wed, 16 Jul 2014 06:05:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: gdb X-Bugzilla-Version: 7.7 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: gdb at dima dot secretsauce.net X-Bugzilla-Status: NEW X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-q3/txt/msg00102.txt.bz2 https://sourceware.org/bugzilla/show_bug.cgi?id=17161 Bug ID: 17161 Summary: gdb confused about variable address in a nested function Product: gdb Version: 7.7 Status: NEW Severity: normal Priority: P2 Component: gdb Assignee: unassigned at sourceware dot org Reporter: gdb at dima dot secretsauce.net I have this C program: int main(void) { int v = 0; int b(void) { return v; } int a(void) { return b(); } return a(); } I build like this: $ gcc-4.9 -g -std=gnu11 -o tst tst.c The program runs without surprises. What IS surprising is what gdb thinks is the value of v and &v at various points. At "return a()" and inside b() gdb is correct: (gdb) p v $32 = 0 (gdb) p &v $33 = (int *) 0x7fffffffe450 However inside a(), gdb is confused about the address and the value of v: (gdb) s a () at tst.c:12 (gdb) p v $34 = 5658608 (gdb) p &v $35 = (int *) 0x7fffffffe430 This causes unnecessary confusion, I think. I'm using Debian/sid on an amd64 box. The gdb Debian package is version 7.7.1-2, although I was seeing this with 7.6 as well. Thanks dima -- You are receiving this mail because: You are on the CC list for the bug.