This is the mail archive of the 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]

Variable values before initialisaton

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.


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

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