build warning question - gcc 4.4.5

Marc Glisse marc.glisse@inria.fr
Mon Jan 6 12:43:00 GMT 2014


On Mon, 6 Jan 2014, Nicholas Mc Guire wrote:

> during Linux kernel build I got the following build warning
>
> kernel/trace/trace.c: In function 'tracing_mark_write':
> kernel/trace/trace.c:3818: warning: 'page2' may be used uninitialized in this function
>
> after looking at this function I was not able to figure out how
> this uninitialized usage could happen - all access to page2
> is "protected" by an "if (nr_pages == 2)" so no uninitialized
> access should be possible.

Note the word "may": gcc isn't able (at least at this optimization level) 
to prove that page2 is always initialized before use, so it warns.

> is there some way to make gcc happy here ?

Initialize page2 to 0 where you declare it?

-- 
Marc Glisse



More information about the Gcc-help mailing list