[cfe-dev] uninitialized variable warning, etc

रजनीश rdogra at earthlink.net
Fri Mar 6 23:45:06 PST 2009


Here are some examples taken from ffmpeg-export-2008-12-18


         s->inter_quant_bias=-(1<<(QUANT_BIAS_SHIFT-2)); //(a - x/4)/x

             for(change=-1; change<=1; change+=2){

         next_dir=-1;

         for(mv=-(16<<f_code); mv<(16<<f_code); mv++){

     c=d=e=-1;

             pred_table[0]=-2;

                 lpc[i][j]=-m[(pass-1)&1].coeff[i][j];


On Mar 6, 2009, at 11:14 PM, Chris Lattner wrote:

>
> On Mar 6, 2009, at 2:11 PM, Eli Friedman wrote:
>
>> On Thu, Mar 5, 2009 at 6:36 PM,  <rdogra at earthlink.net> wrote:
>>> test.c: In function ‘main’:
>>> test.c:8: warning: format ‘%s’ expects type ‘char *’, but argument 2
>>
>> There's a TODO in the code to add this check.
>>
>>> has type ‘int’
>>> test.c:7: warning: ‘b’ is used uninitialized in this function
>>
>> clang doesn't have a warning like this as part of the default
>> compilation process, at least for the moment.  There is a separate
>> analysis module which prints warnings like this, though; see
>> http://clang.llvm.org/StaticAnalysis.html.
>
> Right, note that GCC only produces "dataflow warnings" when  
> optimizations are enabled though.
>
>>> libavcodec/dsputil.c:3966:10: warning: use of unary operator that  
>>> may
>>> be intended as compound assignment (-=)
>>
>> This warning triggers on a lot of stuff... we should probably disable
>> it by default.
>
> What sorts of cases does it trigger on that are false positives?
>
> -Chris





More information about the cfe-dev mailing list