Skip to content

Commit 4906236

Browse files
committed
Decouple pointer-check and pointer-arithmetic overflow
In 0779bbd additional checks for arithmetic overflow on pointer arithmetic were added, and enabled implicitly when --pointer-check was set. This is now decoupled and a new option --pointer-overflow-check is available.
1 parent 8fe5d41 commit 4906236

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/analyses/goto_check.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class goto_checkt
4040
enable_div_by_zero_check=_options.get_bool_option("div-by-zero-check");
4141
enable_signed_overflow_check=_options.get_bool_option("signed-overflow-check");
4242
enable_unsigned_overflow_check=_options.get_bool_option("unsigned-overflow-check");
43+
enable_pointer_overflow_check=_options.get_bool_option("pointer-overflow-check");
4344
enable_undefined_shift_check=_options.get_bool_option("undefined-shift-check");
4445
enable_float_overflow_check=_options.get_bool_option("float-overflow-check");
4546
enable_simplify=_options.get_bool_option("simplify");
@@ -103,6 +104,7 @@ class goto_checkt
103104
bool enable_div_by_zero_check;
104105
bool enable_signed_overflow_check;
105106
bool enable_unsigned_overflow_check;
107+
bool enable_pointer_overflow_check;
106108
bool enable_undefined_shift_check;
107109
bool enable_float_overflow_check;
108110
bool enable_simplify;
@@ -899,7 +901,7 @@ void goto_checkt::pointer_overflow_check(
899901
const exprt &expr,
900902
const guardt &guard)
901903
{
902-
if(!enable_pointer_check)
904+
if(!enable_pointer_overflow_check)
903905
return;
904906

905907
if(expr.id()==ID_plus ||

src/analyses/goto_check.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ void goto_check(
3232
#define GOTO_CHECK_OPTIONS \
3333
"(bounds-check)(pointer-check)(memory-leak-check)" \
3434
"(div-by-zero-check)(signed-overflow-check)(unsigned-overflow-check)" \
35-
"(undefined-shift-check)" \
35+
"(pointer-overflow-check)(undefined-shift-check)" \
3636
"(float-overflow-check)(nan-check)"
3737

3838
#define GOTO_CHECK_HELP \
@@ -42,6 +42,7 @@ void goto_check(
4242
" --div-by-zero-check enable division by zero checks\n" \
4343
" --signed-overflow-check enable signed arithmetic over- and underflow checks\n" \
4444
" --unsigned-overflow-check enable arithmetic over- and underflow checks\n" \
45+
" --pointer-overflow-check enable pointer arithmetic over- and underflow checks\n" \
4546
" --undefined-shift-check check shift greater than bit-width\n" \
4647
" --float-overflow-check check floating-point for +/-Inf\n" \
4748
" --nan-check check floating-point for NaN\n" \
@@ -53,6 +54,7 @@ void goto_check(
5354
options.set_option("div-by-zero-check", cmdline.isset("div-by-zero-check")); \
5455
options.set_option("signed-overflow-check", cmdline.isset("signed-overflow-check")); \
5556
options.set_option("unsigned-overflow-check", cmdline.isset("unsigned-overflow-check")); \
57+
options.set_option("pointer-overflow-check", cmdline.isset("pointer-overflow-check")); \
5658
options.set_option("undefined-shift-check", cmdline.isset("undefined-shift-check")); \
5759
options.set_option("float-overflow-check", cmdline.isset("float-overflow-check")); \
5860
options.set_option("nan-check", cmdline.isset("nan-check"))

0 commit comments

Comments
 (0)