This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: warning: '<some_var>' may be used uninitialized in this function
- From: Diego Novillo <dnovillo at redhat dot com>
- To: gcc at gcc dot gnu dot org
- Cc: Christian dot Iseli at licr dot org
- Date: Thu, 12 Jan 2006 10:01:54 -0500
- Subject: Re: warning: '<some_var>' may be used uninitialized in this function
- References: <200601121453.k0CErE1L021586@ludwig-alpha.unil.ch>
On Thursday 12 January 2006 09:53, Christian.Iseli@licr.org wrote:
> On my FC4 box with gcc version 4.0.2 20051125 (Red Hat 4.0.2-8) it says:
> testit.c: In function 'testit':
> testit.c:6: warning: 'best.d' may be used uninitialized in this function
>
The warning is valid. You are not guaranteeing that best.d will be
initialized. What if all the values in array 'a' are < 0?
Your best bet is
struct {int score; int d;} best = {0,0};