[GRASS5] GRASS 5.1 v.in.ascii bug

Glynn Clements glynn.clements at virgin.net
Thu May 8 07:49:44 EDT 2003


Radim Blazek wrote:

> Some of 'uninitialized' may be bugs and when I get this warning
> (in new code) I usually try to fix it. However, sometimes I don't know
> how to (cleanly) avoid this warning. For example on:
> 
> int main( int argc, char **argv ) {
>     int i, a, x;
>     a = rand();
>     if ( a ) {
>         i = 1;
>         x = 0;
>     } else {
>         i = 0;
>     }
>     if ( i ) printf ("%d\n", x);
>     exit (0);
> }
> 
> gcc -Wall prints: warning: `x' might be used uninitialized in this function
> IMHO it may not be used uninitialized. Am I missing something?  

As the error says, it *might* be used uninitialised. gcc doesn't
perform exhaustive analysis of the program logic. It just keeps track
of whether a variable is known to have been initialised in a given
context (in the sense of yes/no/maybe; not in the sense of
yes/no/only-if-i-is-non-zero).

-- 
Glynn Clements <glynn.clements at virgin.net>




More information about the grass-dev mailing list