While compiling uClibc, I saw a warning and narrowed it down.  When I use this
invocation of gcc 4.1.2 (on Debian sid):

$ gcc -c short_des.c -Wall -Os -fno-tree-dominator-opts

I get the following warning:

short_des.c: In function '__des_crypt':
short_des.c:7: warning: 'f' may be used uninitialized in this function

In the attached code snippet, there is no 'f' even defined in __des_crypt(),
and the 'f' being referred to is in a function do_des() that is called from
__des_crypt().  Further, the warning is incorrect even within do_des() -- it is
being set before being used within a loop that will always execute at least 16
times.

This warning does not occur in 4.3.0, so it has been fixed since then; whether
it makes sense to fix it in further 4.1 versions is not clear to me.  It's not
critical, and the workaround is very straightforward (add an initialization to
'f', in this case).


-- 
           Summary: invalid warning that a variable is being used before
                    being initialized
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ahs3 at fc dot hp dot com
 GCC build triplet: ia64-linux-gnu-gcc
  GCC host triplet: ia64-linux-gnu-gcc
GCC target triplet: ia64-linux-gnu-gcc


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31181

Reply via email to