[LCP]macro execution

Vincent Penquerc'h vincent at qubesoft.com
Tue Aug 14 22:02:40 UTC 2001


>     This seems interesting can u suggest one such example?????
> If the initialization u mean is the initialization defined by the language
> then leave it.

If you mean an example of spurious 'uninitialized' warning,
then this code would trigger one:

int foo(int a,int b)
{
  int b;
  if (a<0) {
    b=bar(a);
  }
  baz();
  if (a<0) return b;
  return 0;
}

In this case, b will never be used unititialized, but the
compiler might not see it. This case is simple, but there
are similar ones more complicated where the flow is not so
obvious to follow, even for a compiler.
Note that this function, and many others, can be rewritten
to avoid the warning (and be cleaner, sometimes). I also
have seen stuff like:

int i=0;
while(foo()) {
  int b=i;
}

and GCC (2.95) warning that i was being used uninitialized.
The code was a bit more complicated, granted, but there was
no trick like in the first example.

--
Lyrian




More information about the linuxCprogramming mailing list