-
Notifications
You must be signed in to change notification settings - Fork 273
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
GOTO conversion of return
inside if-then-else
generates unreachable instructions
#7974
Comments
Hi @thomasspriggs , I stumbled upon this while testing #7944. Is there anything that can be done for this case as well ? |
Hi @remi-delmas-3000. Thank you for taking the time to do the testing. I would say that the existing output is technically correct though unhelpful. This is because the end of the code block is not reachable due to the return statement, though it is unhelpful to point this out due to the lack of user code in this location. For comparison consider this variation on your example -
With cbmc as it currently stands on This leaves us with a couple of potential solutions -
Option 1 should be fairly straight forward to implement. It would however leave the possibility of similar issues being found in future for other control flow constructions. Option 2 is the more robust solution in my view, as it should exclude other variations of the same issue with the minor draw back that other user-specified goto statements could also be excluded from coverage checks. The other side-issue I see here is the granularity of reporting which we produce for the coverage output. We currently only list line numbers for each given block. More detailed output could help with making sense of what each individual block is referring to. That would however be more of a feature request than a bugfix. |
I am unassigning myself from this for the moment. I consider this to be outside of the scope of the work which we are currently engaged in, but I will leave @TGWDB assigned, for future prioritisation. |
A PR with the fix for the current issue has been created at #8001 |
When a
return
statement terminates a block in anif-then-else
, GOTO conversion emits :return
As a result
--cover location
reports that the block containing the second GOTO statement is unreachable.Since both GOTO statements have the same source location and there is nothing after the return statement, this makes it look like the return statement is both reachable and unreachable for a user looking at the C code.
Would it be possible to simplify away the second GOTO since it is purely an artifact of goto conversion and statically unreachable ?
Coverage results:
Goto functions :
CBMC version: 5.94.0
Operating system: linux
Exact command line resulting in the issue: cbmc --cover locations main.c
What behaviour did you expect: all blocks reachable
What happened instead: some dead blocks are not reachable
The text was updated successfully, but these errors were encountered: