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: Christian dot Iseli at licr dot org
- Cc: gcc at gcc dot gnu dot org, Perry Smith <pedz at easesoftware dot net>
- Date: Thu, 12 Jan 2006 10:53:10 -0500
- Subject: Re: warning: '<some_var>' may be used uninitialized in this function
- References: <200601121547.k0CFlQs4022575@ludwig-alpha.unil.ch>
On Thursday 12 January 2006 10:47, Christian.Iseli@licr.org wrote:
> But... it used to be the case that the compiler didn't try to warn about
> uninitialized variables embedded in structs (or so I seem to
> remember...) So I was wondering if this was some kind of regression...
>
Progression, of sorts. Your structure is being scalarized, and as it
happens, the compiler is probably using best.d as a loop induction
variable (try -fdump-tree-all and see the .c.t*.optimized dump).
> Of course, initializing best.d is an easy way out, but it's sub-optimal
> and useless.
>
Sub-optimal?
> The "struct {unsigned int score; unsigned int d;} best = best;" trick
> seems to work fine and has no influence on the generated code.
>
Neither will the explicit initialization, which I find more readable. But
it's your code, so *shrug*.