bug-grep
[Top][All Lists]
Advanced

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

bug#17754: Gcc 4.8.2 -Werror=maybe-unused warning in dfa.c


From: behoffski
Subject: bug#17754: Gcc 4.8.2 -Werror=maybe-unused warning in dfa.c
Date: Wed, 11 Jun 2014 23:39:32 +0930
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0

G'day,

Just upgraded to a recent release of gcc (previously I was running
4.7.x):
    $ gcc --version
    gcc (Gentoo 4.8.2 p1.3r1, pie-0.5.8r1) 4.8.2
    Copyright (C) 2013 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

It complains about an stack variable, mbclen, possibly being
used uninitialised in a call to transit_state_consume_1char.

The warning message is (I'm still at 2.20 post-admin commit
....78f07b8c8e26):

    make[2]: Entering directory `/home/grep-gnu/grep/src'
      CC       dfa.o
    dfa.c: In function 'transit_state':
    dfa.c:3213:31: error: 'mbclen' may be used uninitialized in this function 
[-Werror=maybe-uninitialized]
       transit_state_consume_1char (d, s, pp, wc, mbclen, match_lens);
                                   ^
    cc1: all warnings being treated as errors
    make[2]: *** [dfa.o] Error 1
    make[2]: Leaving directory `/home/grep-gnu/grep/src

The earlier version of gcc did not complain about this code.

Reading through the code, it looks that the offending line is
only reached if (nelem > 0), and, if so, mbclen is initialised
earlier.  At the expense of some code duplication, or perhaps
the judicious use of a couple of goto's, the
(nelem == 0 || maxlen == 0) block could be split up and rearranged
such that the connection between the preceding paragraph
(nelem > 0) and the following paragraphs (transit_state_consume_1char)
would become more apparent, and the fact that mbclen is always
initialised would become clear, both to the reader and the
compiler.

cheers,

behoffski (Brenton Hoff)
Programmer, Grouse Software





reply via email to

[Prev in Thread] Current Thread [Next in Thread]