From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5485 invoked by alias); 23 Nov 2006 17:32:46 -0000 Received: (qmail 5477 invoked by uid 22791); 23 Nov 2006 17:32:45 -0000 X-Spam-Check-By: sourceware.org Received: from wx-out-0506.google.com (HELO wx-out-0506.google.com) (66.249.82.227) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 23 Nov 2006 17:32:41 +0000 Received: by wx-out-0506.google.com with SMTP id h26so652378wxd for ; Thu, 23 Nov 2006 09:32:39 -0800 (PST) Received: by 10.70.22.10 with SMTP id 10mr3291777wxv.1164303159613; Thu, 23 Nov 2006 09:32:39 -0800 (PST) Received: by 10.70.12.9 with HTTP; Thu, 23 Nov 2006 09:32:39 -0800 (PST) Message-ID: Date: Thu, 23 Nov 2006 17:32:00 -0000 From: "Rob Quill" To: gdb@sourceware.org Subject: Variable values before initialisaton In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: X-IsSubscribed: yes 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 X-SW-Source: 2006-11/txt/msg00162.txt.bz2 How could I go about looking into a fix? I wouldn't really know where to start, but it is quite annoying for what am trying to do. Thanks for your help. Rob On 23/11/06, Vladimir Prus wrote: > Rob Quill wrote: > > > Hi, > > > > Sorry to ask to many questions in one day. but I was wondering fi > > anyone could explain why a variable can have a value before it has > > been declared. > > > > In my code I have: > > > > int i = 0; > > int j = 2; > > int k = 3; > > > > and if I print the value of k any time before it has been set to 3, it > > get it being equal to a very large number, rather than it not being in > > the current scope. Is this a debugging thing, or something to do with > > the way the code is compiled, or something else? > > You're extremely lucky you've int variables, and not C++ classes, and not > trying to call member functions of those. > > The gdb/gcc combination has the bad habit of including not-yet-created > variables in the list of local variables. I don't think anybody's working > on a fix. > > - Volodya > > >