File tree Expand file tree Collapse file tree 3 files changed +38
-5
lines changed
regression/cbmc/dynamic_size1 Expand file tree Collapse file tree 3 files changed +38
-5
lines changed Original file line number Diff line number Diff line change
1
+ struct S
2
+ {
3
+ __CPROVER_size_t size ;
4
+ char * p ;
5
+ };
6
+
7
+ void func (struct S * s )
8
+ {
9
+ char * p = s -> p ;
10
+ __CPROVER_size_t size = __CPROVER_OBJECT_SIZE (p );
11
+ __CPROVER_assert (size == s -> size , "size ok" );
12
+ p [80 ] = 123 ; // should be safe
13
+ }
14
+
15
+ int main ()
16
+ {
17
+ __CPROVER_size_t buffer_size ;
18
+ __CPROVER_assume (buffer_size >= 100 );
19
+ char buffer [buffer_size ];
20
+ struct S s ;
21
+ s .size = buffer_size ;
22
+ s .p = buffer ;
23
+ func (& s );
24
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ stack_object.c
3
+ --pointer-check
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^VERIFICATION SUCCESSFUL$
7
+ --
8
+ ^warning: ignoring
Original file line number Diff line number Diff line change @@ -786,7 +786,7 @@ void bv_pointerst::do_postponed(
786
786
{
787
787
const exprt &expr=*it;
788
788
789
- mp_integer object_size;
789
+ exprt object_size;
790
790
791
791
if (expr.id ()==ID_symbol)
792
792
{
@@ -798,8 +798,8 @@ void bv_pointerst::do_postponed(
798
798
if (size_expr.is_nil ())
799
799
continue ;
800
800
801
- if ( to_integer (size_expr, object_size))
802
- continue ;
801
+ object_size =
802
+ typecast_exprt::conditional_cast (size_expr, postponed. expr . type ()) ;
803
803
}
804
804
else
805
805
continue ;
@@ -813,12 +813,13 @@ void bv_pointerst::do_postponed(
813
813
bvt saved_bv=postponed.op ;
814
814
saved_bv.erase (saved_bv.begin (), saved_bv.begin ()+offset_bits);
815
815
816
+ bvt size_bv = convert_bv (object_size);
817
+
816
818
POSTCONDITION (bv.size ()==saved_bv.size ());
817
819
PRECONDITION (postponed.bv .size ()>=1 );
820
+ PRECONDITION (size_bv.size () == postponed.bv .size ());
818
821
819
822
literalt l1=bv_utils.equal (bv, saved_bv);
820
-
821
- bvt size_bv=bv_utils.build_constant (object_size, postponed.bv .size ());
822
823
literalt l2=bv_utils.equal (postponed.bv , size_bv);
823
824
824
825
prop.l_set_to (prop.limplies (l1, l2), true );
You can’t perform that action at this time.
0 commit comments