Skip to content

Commit

Permalink
C library: implement feraiseexcept
Browse files Browse the repository at this point in the history
Model floating-point exceptions as failing assertions.
  • Loading branch information
tautschnig committed Feb 7, 2024
1 parent a1c67b7 commit 5c012e6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
9 changes: 9 additions & 0 deletions regression/cbmc-library/feraiseexcept-01/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <assert.h>
#include <fenv.h>

int main()
{
int exceptions;
feraiseexcept(exceptions);
return 0;
}
8 changes: 8 additions & 0 deletions regression/cbmc-library/feraiseexcept-01/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE
main.c

^VERIFICATION FAILED$
^EXIT=10$
^SIGNAL=0$
--
^warning: ignoring
9 changes: 9 additions & 0 deletions src/ansi-c/library/fenv.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,12 @@ __CPROVER_HIDE:;
0;
return 0; // we never fail
}

/* FUNCTION: feraiseexcept */

int feraiseexcept(int excepts)
{
__CPROVER_HIDE:;
__CPROVER_assert(excepts == 0, "floating-point exception");
return 0; // we never fail
}

0 comments on commit 5c012e6

Please sign in to comment.