#90 Missing default cases in generated scanner.

2.6.0
open
nobody
5
2015-11-18
2008-10-28
No

I'm working on a large project, that uses a couple of flex-generated scanners. The project tries to use as much warning settings in the compiler as possible, including -Wswitch-default. However, the flex-generated scanner is missing some default cases in switch statements.

I am aware of the fact that such warnings are not high priority, but at the same time, if it's all the same for the functionality of flex, then it would be great if such default cases can be added.

I can provide a patch to fix this, so that minimal work needs to be done by the maintainers. Before spending time on fixing it, I would like to know whether it would be accepted.

thank you very much,
kjs

Discussion

  • Will Estes

    Will Estes - 2008-12-28
    • milestone: --> 2.5.35
    • assigned_to: nobody --> wlestes
     
  • Will Estes

    Will Estes - 2012-02-04
    • assigned_to: wlestes --> nobody
     
  • Tim Landscheidt

    Tim Landscheidt - 2012-02-20

    Thanks for the suggestion. I am a bit hesitant about this. If we just randomly designate one of the cases as "default":

    1. for a new developer, it might look as if yy_get_next_buffer()'s return value could be "anything" and he might code accordingly, and
    2. if we would introduce a bug in yy_get_next_buffer(), it might be masked by the catch-all case.

    On the other hand, if we assert() that the default case is never reached, we might create performance issues (though unlikely) and certainly look less than confident in our own code :-).

    I understand and support the position that code generated by flex should not generate warnings as the actions supplied by the user are interlaced in it and can only be warned of if the surrounding code is "clean". GCC 4.4 provides "#pragma"s that could be used to disable warnings for the issue at hand; unfortunately, in other compilers there will be other "#pragma"s. So my hunch would be to add GCC "#pragma"s that are ignored by other compilers and then add "#pragma"s for other compilers when the need arises.

     
  • Will Estes

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

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

Sign up for the SourceForge newsletter:





No, thanks