delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/03/05/13:08:37

Message-Id: <m0w2F6z-000S1oC@natacha.inti.edu.ar>
Comments: Authenticated sender is <salvador AT natacha DOT inti DOT edu DOT ar>
From: "Salvador Eduardo Tropea (SET)" <salvador AT natacha DOT inti DOT edu DOT ar>
Organization: INTI
To: "A.Appleyard" <A DOT APPLEYARD AT fs2 DOT mt DOT umist DOT ac DOT uk>
Date: Wed, 5 Mar 1997 14:57:08 +0000
MIME-Version: 1.0
Subject: Re: False alarm of variable used uninitialized
CC: djgpp AT delorie DOT com

A.Appleyard wrote:
> C:\AM>type __.cc
> #include<stdio.h>
> void zxcvbnm(int A,int B){int C;
> if(A==2 ?: (C=A+B)<5) return;
> printf("%1d\n",C);}
> /*-----*/
> main(){zxcvbnm(5,6);;}
> 
> C:\AM>gcc __.cc -O2 -Wall
> __.cc: In function `void zxcvbnm(int, int)':
> __.cc:2: warning: `int C' might be used uninitialized in this function
> 
> There seems to be a logical fault in deciding when C `might be used
> uninitialized in this function', as the if-branch `A==2' (which does not set
> C) here leads straight to a return and not to anything mentioning C again.

  I saw other situations where a human can analyze that the variable will be 
initialized but GCC claims that not. Seems that this part of GCC is a little 
weak. When I come to these situations I simply force an initialization to avoid 
the warning, I think that 3 o 4 extra assigments in 500Kb of code aren't so bad 
but of course could be better if GCC worked better. You can post your wish to 
the GNU/FSF people.

SET
--------------- 0 --------------------------------
Salvador Eduardo Tropea (SET).
Address: Curapaligue 2124, Caseros, 3 de Febrero
Buenos Aires, (1678), ARGENTINA
TE: +(541) 759 0013

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019