-
Notifications
You must be signed in to change notification settings - Fork 184
-f with -b/-g generates incorrect dispatch on fill labels #119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
skvadrik
added a commit
that referenced
this issue
Aug 25, 2015
…abels". Consider the following example 1.re: /*!re2c "" {} */ With -if, re2c would generate correct dispatch: $ re2c -if 1.re /* Generated by re2c 0.14.3 on Tue Aug 25 10:41:45 2015 */ switch (YYGETSTATE()) { default: goto yy0; case 0: goto yyFillLabel0; } yy0: YYSETSTATE(0); yyFillLabel0: {} With -bif all positive YYGETSTATE() values will lead to yyFillLabel0, which is clearly an error: values that are greater than 0 should lead to yy0: $ re2c -bif 1.re /* Generated by re2c 0.14.3 on Tue Aug 25 10:40:32 2015 */ if (YYGETSTATE() < 0) { goto yy0; } else { goto yyFillLabel0; } yy0: YYSETSTATE(0); yyFillLabel0: {} With -gif the error is different: all values greater than 0 now cause undefined behaviour (access to memory not within array bounds): $ re2c -gif 1.re /* Generated by re2c 0.14.3 on Tue Aug 25 10:47:41 2015 */ { static void *yystable[] = { &&yyFillLabel0, }; if (YYGETSTATE() < 0) { goto yy0; } goto *yystable[YYGETSTATE()]; yy0: YYSETSTATE(0); yyFillLabel0: {} } The situation gets even more tricky with re2c:state:abort configuration. Besides, YYGETSTATE() macro is called multiple times with -b and -g, which is not so good. Additional checks with -g don't help gain performance either. Fix: always generate simple switch.
Fixed, see this commit. Now re2c with |
skvadrik
added a commit
that referenced
this issue
Oct 16, 2015
… on fill labels". Somehow configuration 're2c:state:abort = 1;' was present in all the tests; it was meant to be only in half of them.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Consider the following example 1.re:
With
-if
, re2c would generate correct dispatch:With
-bif
all positiveYYGETSTATE()
values will lead toyyFillLabel0
, which is clearly an error: values that are greater than0
should lead toyy0
:With
-gif
the error is different: all values greater than0
now cause undefined behaviour (access to memory not within array bounds):The situation gets even more tricky if we add
re2c:state:abort
configuration (2.re):Correct dispatch with
-if
looks like this:With
-bif
call toabort()
is unreachable:With
-gif
we still get undefined behaviour for all values greater than0
:Besides,
YYGETSTATE()
macro is called multiple times with-b
and-g
, which is not so good. Additional checks with-g
don't help either.The text was updated successfully, but these errors were encountered: