diff --git a/regression/goto-instrument/stack-depth1/fails.desc b/regression/goto-instrument/stack-depth1/fails.desc new file mode 100644 index 00000000000..b8985e710ac --- /dev/null +++ b/regression/goto-instrument/stack-depth1/fails.desc @@ -0,0 +1,8 @@ +CORE +main.c +--stack-depth 1 +^EXIT=10$ +^SIGNAL=0$ +VERIFICATION FAILED +-- +^warning: ignoring diff --git a/regression/goto-instrument/stack-depth1/main.c b/regression/goto-instrument/stack-depth1/main.c new file mode 100644 index 00000000000..7422dc1ec25 --- /dev/null +++ b/regression/goto-instrument/stack-depth1/main.c @@ -0,0 +1,14 @@ +int bar(int x) +{ + return 42; +} + +int foo(int x) +{ + return bar(x); +} + +int main(int argc, char* argv[]) +{ + return foo(argc); +} diff --git a/regression/goto-instrument/stack-depth1/test.desc b/regression/goto-instrument/stack-depth1/test.desc new file mode 100644 index 00000000000..d6829851a6e --- /dev/null +++ b/regression/goto-instrument/stack-depth1/test.desc @@ -0,0 +1,8 @@ +CORE +main.c +--stack-depth 2 +^EXIT=0$ +^SIGNAL=0$ +VERIFICATION SUCCESSFUL +-- +^warning: ignoring diff --git a/src/goto-instrument/goto_instrument_parse_options.cpp b/src/goto-instrument/goto_instrument_parse_options.cpp index cd4acd233c5..34fa97276c2 100644 --- a/src/goto-instrument/goto_instrument_parse_options.cpp +++ b/src/goto-instrument/goto_instrument_parse_options.cpp @@ -1175,7 +1175,7 @@ void goto_instrument_parse_optionst::instrument_goto_program() status() << "Adding check for maximum call stack size" << eom; stack_depth( goto_model, - unsafe_string2unsigned(cmdline.get_value("stack-depth"))); + safe_string2size_t(cmdline.get_value("stack-depth"))); } // ignore default/user-specified initialization of variables with static diff --git a/src/goto-instrument/stack_depth.cpp b/src/goto-instrument/stack_depth.cpp index 581d5c1bb74..7783ceda830 100644 --- a/src/goto-instrument/stack_depth.cpp +++ b/src/goto-instrument/stack_depth.cpp @@ -22,7 +22,7 @@ Date: November 2011 symbol_exprt add_stack_depth_symbol(symbol_tablet &symbol_table) { const irep_idt identifier="$stack_depth"; - signedbv_typet type(sizeof(int)*8); + unsignedbv_typet type(sizeof(std::size_t)*8); symbolt new_symbol; new_symbol.name=identifier; @@ -43,7 +43,7 @@ symbol_exprt add_stack_depth_symbol(symbol_tablet &symbol_table) void stack_depth( goto_programt &goto_program, const symbol_exprt &symbol, - const int i_depth, + const std::size_t i_depth, const exprt &max_depth) { assert(!goto_program.instructions.empty()); @@ -82,7 +82,7 @@ void stack_depth( void stack_depth( goto_modelt &goto_model, - const int depth) + const std::size_t depth) { const symbol_exprt sym= add_stack_depth_symbol(goto_model.symbol_table); diff --git a/src/goto-instrument/stack_depth.h b/src/goto-instrument/stack_depth.h index d63037116ac..666adbcc59b 100644 --- a/src/goto-instrument/stack_depth.h +++ b/src/goto-instrument/stack_depth.h @@ -14,10 +14,12 @@ Date: November 2011 #ifndef CPROVER_GOTO_INSTRUMENT_STACK_DEPTH_H #define CPROVER_GOTO_INSTRUMENT_STACK_DEPTH_H +#include + class goto_modelt; void stack_depth( goto_modelt &, - const int depth); + const std::size_t depth); #endif // CPROVER_GOTO_INSTRUMENT_STACK_DEPTH_H