Skip to content

Commit e3ad659

Browse files
author
Daniel Kroening
authored
Merge pull request #955 from tautschnig/void-cast
Properly handle void*
2 parents 5e6b593 + 7f6443b commit e3ad659

File tree

95 files changed

+250
-135
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+250
-135
lines changed

regression/cbmc/void_pointer1/main.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
char buffer[2];
2+
int length = 2;
3+
4+
void func(void* buf, int len)
5+
{
6+
while( len-- )
7+
*(char *)buf++;
8+
}
9+
10+
void main(){
11+
func(buffer,length);
12+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--pointer-check
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring

regression/cbmc/void_pointer2/main.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
char buffer[2];
2+
int length = 2;
3+
4+
void func(void* buf, int len)
5+
{
6+
while( len-- )
7+
*(char *)buf++;
8+
}
9+
10+
void main(){
11+
func(buffer,length);
12+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--pointer-check --no-simplify --unwind 3
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring

src/analyses/goto_check.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1238,7 +1238,8 @@ void goto_checkt::bounds_check(
12381238
plus_exprt effective_offset(ode.offset(), pointer_offset(pointer));
12391239

12401240
assert(effective_offset.op0().type()==effective_offset.op1().type());
1241-
assert(effective_offset.type()==size.type());
1241+
if(effective_offset.type()!=size.type())
1242+
size.make_typecast(effective_offset.type());
12421243

12431244
binary_relation_exprt inequality(effective_offset, ID_lt, size);
12441245

src/analyses/goto_rw.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ void rw_range_sett::get_objects_complex(
149149

150150
range_spect sub_size=
151151
to_range_spect(pointer_offset_bits(op.type().subtype(), ns));
152+
assert(sub_size>0);
152153
range_spect offset=
153154
(range_start==-1 || expr.id()==ID_complex_real) ? 0 : sub_size;
154155

src/analyses/invariant_set.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Author: Daniel Kroening, [email protected]
1616
#include <util/base_type.h>
1717
#include <util/std_types.h>
1818

19-
#include <ansi-c/c_types.h>
19+
#include <util/c_types.h>
2020
#include <langapi/language_util.h>
2121

2222
#include "invariant_set.h"

src/analyses/local_bitvector_analysis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Author: Daniel Kroening, [email protected]
1313
#include <util/std_code.h>
1414
#include <util/expr_util.h>
1515

16-
#include <ansi-c/c_types.h>
16+
#include <util/c_types.h>
1717
#include <langapi/language_util.h>
1818

1919
#include "local_bitvector_analysis.h"

src/analyses/local_cfg.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Author: Daniel Kroening, [email protected]
1414
#include <util/std_code.h>
1515
#include <util/expr_util.h>
1616

17-
#include <ansi-c/c_types.h>
17+
#include <util/c_types.h>
1818
#include <langapi/language_util.h>
1919

2020
#endif

src/analyses/local_may_alias.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Author: Daniel Kroening, [email protected]
1313
#include <util/std_expr.h>
1414
#include <util/std_code.h>
1515

16-
#include <ansi-c/c_types.h>
16+
#include <util/c_types.h>
1717
#include <langapi/language_util.h>
1818

1919
#include "local_may_alias.h"

0 commit comments

Comments
 (0)