Avoid warning about not returning a value [blocks: #2548]#3414
Avoid warning about not returning a value [blocks: #2548]#3414tautschnig merged 5 commits intodiffblue:developfrom
Conversation
|
Won't that backfire, i.e., generate warnings about dead code? |
Not as far as I can tell, but maybe #2548 has other changes hiding such warnings, so we'll see when CI passes over here (where there really is just this one commit). |
allredj
left a comment
There was a problem hiding this comment.
✔️
Passed Diffblue compatibility checks (cbmc commit: 0941f7b).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/91377050
peterschrammel
left a comment
There was a problem hiding this comment.
That's quite awkward. Hm... We could have a variant of these macros that take the return value to make this less ugly (but maybe also more confusing).
|
I am wondering whether the goal here can be achieved by means of the right compiler annotation for "UNREACHABLE" for Visual Studio? |
|
Some use of |
|
@smowton these functions will return, just somewhere else, with a return statement. It needs to be an annotation that says "I promise we won't get here". It might be doable to do that with a throw on VS. |
|
? The important thing here is if we somehow hit an |
|
The relevant function already has a __declspec(noreturn). The problem appears to be that MSVC can't infer that doesn't have a successor for CONDITION = false. |
|
@tautschnig Special-casing the UNREACHABLE macro appears to work! |
0941f7b to
1eeb105
Compare
|
@kroening I believe I have now implemented what you meant by special-casing, but please do confirm. |
1eeb105 to
38f8e77
Compare
38f8e77 to
0aad92f
Compare
allredj
left a comment
There was a problem hiding this comment.
✔️
Passed Diffblue compatibility checks (cbmc commit: 0aad92f).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/95263703
|
Marking do-not-merge: I was likely mislead, the fix might be much simpler, investigating in #2310. |
We previously never set noreturn for Visual Studio.
UNREACHABLE will throw an exception if such an instruction were actually reached.
Also clean up the earlier if(...) return true; return false;
All earlier branches end in a return statement.
0aad92f to
c805422
Compare
allredj
left a comment
There was a problem hiding this comment.
✔️
Passed Diffblue compatibility checks (cbmc commit: c805422).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/95446748
Compilers differ in their ability to infer dead code, and the use of INVARIANT
etc. may result in end-of-function being reachable when they are configured
as no-ops. Make compilers happy, even when that may result in statements that
really shouldn't be reachable.