-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Try all rounding modes when domain is unknown
For rounding modes in constant propagator domain
- Loading branch information
1 parent
d236828
commit d737d60
Showing
3 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
regression/goto-analyzer/constant_propagation_nondet_rounding_mode/main.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include <fenv.h> | ||
#include <stdio.h> | ||
#include <assert.h> | ||
|
||
int nondet_rounding_mode(void); | ||
|
||
int main(void) | ||
{ | ||
// slightly bigger than 0.1 | ||
float f = 1.0f / 10.0f; | ||
|
||
// now we don't know what rounding mode we're in | ||
__CPROVER_rounding_mode = nondet_rounding_mode(); | ||
// depending on rounding mode 1.0f/10.0f could | ||
// be greater or smaller than 0.1 | ||
|
||
// definitely not smaller than -0.1 | ||
assert((1.0f / 10.0f) - f < -0.1f); | ||
// might be smaller than 0 | ||
assert((1.0f / 10.0f) - f < 0.0f); | ||
// definitely smaller or equal to 0 | ||
assert((1.0f / 10.0f) - f <= 0.0f); | ||
// might be greater or equal to 0 | ||
assert((1.0f / 10.0f) - f >= 0.0f); | ||
// definitely not greater than 0 | ||
assert((1.0f / 10.0f) - f > 0.0f); | ||
} |
13 changes: 13 additions & 0 deletions
13
regression/goto-analyzer/constant_propagation_nondet_rounding_mode/test.desc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
CORE | ||
main.c | ||
--constants --verify | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
\[main.assertion.1\] file main.c line 18 function main, assertion \(1.0f / 10.0f\) - f < -0.1f: Failure \(if reachable\) | ||
\[main.assertion.2\] file main.c line 20 function main, assertion \(1.0f / 10.0f\) - f < 0.0f: Unknown | ||
\[main.assertion.3\] file main.c line 22 function main, assertion \(1.0f / 10.0f\) - f <= 0.0f: Success | ||
\[main.assertion.4\] file main.c line 24 function main, assertion \(1.0f / 10.0f\) - f >= 0.0f: Unknown | ||
\[main.assertion.5\] file main.c line 26 function main, assertion \(1.0f / 10.0f\) - f > 0.0f: Failure \(if reachable\) | ||
|
||
-- | ||
^warning: ignoring |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters