Skip to content

Commit a299d48

Browse files
authored
Merge pull request #2418 from tautschnig/vs-stack-depth
stack_depth takes a signed int as argument
2 parents 8000a2f + 4482007 commit a299d48

File tree

6 files changed

+37
-5
lines changed

6 files changed

+37
-5
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--stack-depth 1
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
VERIFICATION FAILED
7+
--
8+
^warning: ignoring
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
int bar(int x)
2+
{
3+
return 42;
4+
}
5+
6+
int foo(int x)
7+
{
8+
return bar(x);
9+
}
10+
11+
int main(int argc, char* argv[])
12+
{
13+
return foo(argc);
14+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--stack-depth 2
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
VERIFICATION SUCCESSFUL
7+
--
8+
^warning: ignoring

src/goto-instrument/goto_instrument_parse_options.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1175,7 +1175,7 @@ void goto_instrument_parse_optionst::instrument_goto_program()
11751175
status() << "Adding check for maximum call stack size" << eom;
11761176
stack_depth(
11771177
goto_model,
1178-
unsafe_string2unsigned(cmdline.get_value("stack-depth")));
1178+
safe_string2size_t(cmdline.get_value("stack-depth")));
11791179
}
11801180

11811181
// ignore default/user-specified initialization of variables with static

src/goto-instrument/stack_depth.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Date: November 2011
2222
symbol_exprt add_stack_depth_symbol(symbol_tablet &symbol_table)
2323
{
2424
const irep_idt identifier="$stack_depth";
25-
signedbv_typet type(sizeof(int)*8);
25+
unsignedbv_typet type(sizeof(std::size_t)*8);
2626

2727
symbolt new_symbol;
2828
new_symbol.name=identifier;
@@ -43,7 +43,7 @@ symbol_exprt add_stack_depth_symbol(symbol_tablet &symbol_table)
4343
void stack_depth(
4444
goto_programt &goto_program,
4545
const symbol_exprt &symbol,
46-
const int i_depth,
46+
const std::size_t i_depth,
4747
const exprt &max_depth)
4848
{
4949
assert(!goto_program.instructions.empty());
@@ -82,7 +82,7 @@ void stack_depth(
8282

8383
void stack_depth(
8484
goto_modelt &goto_model,
85-
const int depth)
85+
const std::size_t depth)
8686
{
8787
const symbol_exprt sym=
8888
add_stack_depth_symbol(goto_model.symbol_table);

src/goto-instrument/stack_depth.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ Date: November 2011
1414
#ifndef CPROVER_GOTO_INSTRUMENT_STACK_DEPTH_H
1515
#define CPROVER_GOTO_INSTRUMENT_STACK_DEPTH_H
1616

17+
#include <cstddef>
18+
1719
class goto_modelt;
1820

1921
void stack_depth(
2022
goto_modelt &,
21-
const int depth);
23+
const std::size_t depth);
2224

2325
#endif // CPROVER_GOTO_INSTRUMENT_STACK_DEPTH_H

0 commit comments

Comments
 (0)