RE: behavior of -Wall

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

 



> I just stumbled upon the fact that -Wall isn't as reliable in reporting the usage of uninitialized variables as I thought.
> Given the following code
>
> int main()
> {
> unsigned int F;
> //unsigned int& G = F;
> if (F==0){F++;}
> }
>
> g++ tells my, as expected "warning: ‘F’ is used uninitialized in this function".
> This is not the case if I uncomment the 4th line, assigning the G alias to F. The same does happen if I declare a function
>
> void foo(unsigned int& F){}
>
> and replace the assignement line with a function call. I do understand, that it would be difficult to follow up all possible aliases of F to rule out the possibility of being non initialized but shouldn't this be a easy enough to detect?

See http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings#Current_Situation

and http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings#Testcases

and in particular http://gcc.gnu.org/PR19430, which is your issue.

Some of the issues may be easy but they need someone to work on them.
If you think you can help, please contribute to the project:

http://gcc.gnu.org/contribute.html

In fact, it would be extremely useful to go through all Wuninitialized
issues and test on current trunk what happens at -O0 -O1 -O2 and -O3.
I think some of them may be fixed now, others may only arise at -O0.

Cheers,

Manuel.



[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