Skip to content
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

yych being set by YYPEEK () and then not used. #182

Closed
pmetzger opened this issue Apr 10, 2017 · 8 comments

Comments

@pmetzger
Copy link

commented Apr 10, 2017

Howdy! Using the clang static analyzer and re2c 0.16, I've found a few instances where the analyzer finds instances of yych = YYPEEK (); where yych is not subsequently used in the control path. Although benign as bugs go, I'd still like to help you fix it.

Not 100% sure how to build a minimizing test case, without which it will be hard for you to track down the bug. Is there a way to figure out from the goto labels in the generated code to particular regular expressions that triggered the construction of that part of the code?

@pmetzger pmetzger changed the title unused yych being set by YYPEEK () and then not used. yych being set by YYPEEK () and then not used. Apr 10, 2017

@skvadrik

This comment has been minimized.

Copy link
Owner

commented Apr 10, 2017

You can build a minimal test case using --skeleton option: http://re2c.org/manual/features/skeleton/skeleton.html
All it needs is regular expressions (everything inside of /*!re2c ... */ blocks), all the interface code is generated automatically. You can make sure that skeleton program builds and still triggers the bug, then post your reduced example, command line and warning report here.

@pmetzger

This comment has been minimized.

Copy link
Author

commented Apr 10, 2017

It seems to build! I'll try bisecting the code until I get a minimal instance.

@pmetzger

This comment has been minimized.

Copy link
Author

commented Apr 10, 2017

Okay, it seems to work! I've produced what isn't quite a minimal instance but it retains all the original warnings I was getting from the clang static analyzer just in case they're somehow different versions of the bug.

Build the attached with:
re2c --bit-vectors --nested-ifs -W -Werror --input custom --skeleton -o test-skeleton.c test-skeleton.re

Then use scan-build or ccc-analyzer directly and you get:

test-skeleton.c:299:9: warning: Value stored to 'yych' is never read
yych = YYPEEK ();
^ ~~~~~~~~~
test-skeleton.c:320:9: warning: Value stored to 'yych' is never read
yych = YYPEEK ();
^ ~~~~~~~~~
test-skeleton.c:376:9: warning: Value stored to 'yych' is never read
yych = YYPEEK ();
^ ~~~~~~~~~
3 warnings generated.
scan-build: 3 bugs found.v

So far as I can tell, the errors are indeed correct.

I will attach test-skeleton.c directly just to make sure you have exactly the same one. (For some reason, github has insisted that I put .txt at the ends of the file names...)

test-skeleton.re.txt
test-skeleton.c.txt

@skvadrik

This comment has been minimized.

Copy link
Owner

commented Apr 10, 2017

Thank you for the detailed report!
The bug has already been fixed in devel branch (I don't recall it, but maybe there was a similar issue somewhere).

@pmetzger

This comment has been minimized.

Copy link
Author

commented Apr 10, 2017

When is the next release version likely to be cut? It seems like there's a lot of good stuff queued up... :)

@skvadrik

This comment has been minimized.

Copy link
Owner

commented Apr 11, 2017

Quite a lot, more than a year of development.
Unfortunately the main change in the upcoming release requires some research: it involves a relatively novel algorithm with a few modifications of my own. I have to formalize the algorithm, and it takes me longer than expected.

@pmetzger

This comment has been minimized.

Copy link
Author

commented Apr 11, 2017

Cool. Is there any way to cherry pick the fixes for some of the other bugs, or is that too hard to do because they're dependent on the new algorithm for generating the automaton?

@skvadrik

This comment has been minimized.

Copy link
Owner

commented Apr 11, 2017

I suppose it's hard. The whole codebase changed since the last release.
I hope it won't be too long until the next release (a month?), but I said the same thing half a year ago and new sub-problems keep showing up.

@skvadrik skvadrik closed this Mar 19, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.