Re: "uninitialized variable" warning from compiler

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Oct 26, 2009 at 7:36 PM, Andrew Haley <aph@xxxxxxxxxx> wrote:
> Umashankar V.K. wrote:
>
>>       I have few questions about  inbuilt mechanism of  gcc/g++  for
>> warning about  uninitialized variable.
>>
>>
>> But then I came across the following  failure case.  This one  fails
>> to  warn when compiled with any  level  below 3.
>> With -O3,  gcc  is able to warn.   Can someone tell me which is the
>> corresponding bug logged at bugzilla ?
>
> I don't understand why you think this is a bug in gcc.  Inlining will
> always reveal more about the data flow of a program.

Of course, I know this is not a bug.  But I didnt choose the term
here. The compiler developers prefer to
call them bugs and track them using bug-zilla.

>
> extern void foo (int *p);
>
> void bar
> {
>  int a;
>  foo (&a);
>
>  printf("%d\n", a);
> }
>
> We could fix gcc so that in every case where we couldn't prove that a variable
> is initialized, we warned.  You'd have to put up with a lot of spurious "may
> be used uninitialized" warnings.
>
> Andrew.
>

yes, i know that false positives is a concern for the compiler author.
  But sometimes, a guy who is wondering
why the hell his board is crashing at random may not mind  going
through a heap of  compiler-warnings if he wants to rule
out that possibility.   A   code-misbehaviour due to  uninitialised
variables can be as mysterious as one due to
stack corruption,  isnt it ?

            shankar

ps -  I choose  plain text for the messages I post.  Still  i  see
strange characters when my post appears at
http://gcc.gnu.org/ml/gcc-help/


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux