Re: Detecting Reads of Global Uninitialized Variables



<jyu.james@xxxxxxxxx> wrote in message
news:1128034028.587595.231600@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> I'm trying to detect reads of uninitialized global variables (that are
> declared in one file, and used in another as an extern).
>
> I know that ANSI C initializes all global variables to 0, however, I do
> not want to rely on this for initialization.

Why not? The language guarantees it.

> Instead, I want to
> explicity initialize all variables myself. I've looked at tools like
> Compuware BoundsChecker, which does an amazing job in detecting
> uninitialized variables, but doesn't detect reads of GLOBAL
> uninitialized variables.

That's because they *are* initialized.

>
> Is there a tool out there that can do this? Or is there a particular
> technique that can be used to automate this?

You'll need some kind of C parser.

-Mike


.



Relevant Pages

  • Re: alpha defined: virtualcnt,titleid,keyid,helplineid,pasteboardid
    ... > Where would I best find EXTERN and GLOBAL variables? ... Going back to the C sources: the definitions and (EXTERN) ... thus finding the header file. ... Another way would be to use the CTAGS program, which keeps trace ...
    (comp.os.vms)
  • Re: Use of extern keyword
    ... > i.e consider a following piece of code from MSDN explaining extern ... > void next ... > Here,if I drop the extern keyword from source file 2 and compile and ... in using global variables, it's much better practice to define the ...
    (comp.lang.c)
  • Re: Use of extern keyword
    ... >> i.e consider a following piece of code from MSDN explaining extern ... >> Here,if I drop the extern keyword from source file 2 and compile and ... > considered to be a tentative declaration. ... > in using global variables, it's much better practice to define the ...
    (comp.lang.c)
  • Re: exporting global variables from dynamically linked libraries
    ... > global variables that I am exporting. ... > declares the variables as extern. ... of those vars in your program and the linker first uses those before using ...
    (comp.os.linux.development.apps)
  • Re: Using a extern variable
    ... include using an extern statement. ... Then place all of your global variables within that class. ... also do any special initialisation and clean up if needed using the CGlobals ... I need to use a global integer and CString variables in a project. ...
    (microsoft.public.pocketpc.developer)