#176 Compiler warning in YY_LESS_LINENO

2.6.0
open
nobody
5
2015-11-18
2014-07-26
No

GCC complains on flex-generated code with:

FILE:207:36: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for ( yyl = n; yyl < yyleng; ++yyl )\ ^
and the patch below fixes the warning:

diff --git a/src/flex.skl b/src/flex.skl
index 5188a5c..f1aa139 100644
--- a/src/flex.skl
+++ b/src/flex.skl
@@ -506,7 +506,7 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
*/
#define YY_LESS_LINENO(n) \ do { \ - int yyl;\ + unsigned int yyl;\ for ( yyl = n; yyl < yyleng; ++yyl )\ if ( yytext[yyl] == '\n' )\ --yylineno;\

Discussion

  • Dilian Wesselinov Palauzov

    The formatting was suboptimal. Just put the word "unsigned" on line 509 before "int yyl;" when defining YY_LESS_LINENO .

     
  • Dilian Wesselinov Palauzov

    In fact the type of yyl shall be changed from int to yy_size_t (which is size_t), as yyleng is defined to be of this type.

     
  • Will Estes

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

Log in to post a comment.

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

Sign up for the SourceForge newsletter:





No, thanks