#129 gcc -Wconversion


I've attached a patch, which would reduce gcc -Wconversion
compiler warnings quite a bit, when compiling flex generated c code.

I disagree a bit with the attitude:
"compiler warnings on flex generated c code are not flex bugs"
When flex is used in a large project, then those warnings
can create quite some noise, and seriously distract attention
from important stuff.

An easy exercise for the attached patch,
is to have a look at flex's own scan.l with
make ; rm scan.c ; make CFLAGS='-O2 -Wconversion'



  • Will Estes

    Will Estes - 2012-03-23
    • assigned_to: nobody --> wlestes
  • Will Estes

    Will Estes - 2012-08-08

    Your patch partially applied. It's on the git branch bug-3341746 in the sourceforge flex git repository if you'd like to submit a patch against that for the rest of the changes you were attempting.

    Please let me know.

  • Robert Larice

    Robert Larice - 2012-08-09

    the following commit:

    commit 9ba3187a537d6a58d345f2874d06087fd4050399
    Date: Thu May 15 21:11:57 2008 +0000
    clean up types; resolves 19619027a537d6a58d345f2874d06087fd4050399

    seems to interfere awfully with my patch.

    at least the change of type for `yyleng'
    from int to yy_size_t (which is unsigned)
    is quite serious.

    yyleng is part of the user API,
    I'm wondering whether this was good to change.

    on the master branch I see in flex.skl now:
    yy_size_t num_to_read ...
    while ( num_to_read <= 0 )
    { /* Not enough room in the buffer - grow it. */
    which makes me nervous, this might be buggy now.

    Please, Whats to do now ?

  • Will Estes

    Will Estes - 2012-11-01
    • status: open --> open-accepted
  • Will Estes

    Will Estes - 2015-11-18
    • Group: --> 2.6.0
  • Will Estes

    Will Estes - 2016-02-27
            See the current state of this patch at:
  • Will Estes

    Will Estes - 2016-02-27
    Not surprising that the patch didn't apply cleanly given the changes in the intervening time between patch submission and me looking at it. That being said, if you could have a look at the remaining conversion warnings and submit an additional patch, I would get it in.
  • Will Estes

    Will Estes - 2016-02-27
    • Description has changed:


    --- old
    +++ new
    @@ -1,4 +1,4 @@
    +    Hello,
     I've attached a patch, which would reduce gcc -Wconversion
     compiler warnings quite a bit, when compiling flex generated c code.
    • status: open-accepted --> closed
  • Will Estes

    Will Estes - 2016-02-27

    I've applied the part of the patch that goes on cleanly. I've created https://github.com/westes/flex/issues/62 as a kind of master ticket where this issue needs to be dealt with on a larger scale. Partial solutions are helpful in as much as they make things better, however. I'm going to delete the sf-129 branch as well.


Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks