File tree 5 files changed +50
-3
lines changed
jbmc/regression/jbmc-strings/long_string
regression/cbmc/constant_folding3 5 files changed +50
-3
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ Test.class
3
3
--function Test.checkAbort --trace
4
4
^EXIT=10$
5
5
^SIGNAL=0$
6
- dynamic_object[0-9]*=\(assignment removed\)
6
+ dynamic_object[0-9]*=.*\?.*
7
7
--
8
8
--
9
9
This tests that the object does not appear in the trace, because concretizing
Original file line number Diff line number Diff line change
1
+ typedef struct _pair
2
+ {
3
+ int x ;
4
+ int y ;
5
+ } pair ;
6
+
7
+ int __VERIFIER_nondet_int ();
8
+
9
+ int main (void )
10
+ {
11
+ pair p1 = {.x = 0 , .y = __VERIFIER_nondet_int ()};
12
+ pair p2 = {};
13
+ p2 .x = __VERIFIER_nondet_int ();
14
+
15
+ __CPROVER_assert (p1 .x == p2 .y , "true by constant propagation" );
16
+
17
+ return 0 ;
18
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ main.c
3
+
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^VERIFICATION SUCCESSFUL$
7
+ ^Generated 1 VCC\(s\), 0 remaining after simplification$
8
+ --
9
+ ^warning: ignoring
Original file line number Diff line number Diff line change @@ -153,6 +153,20 @@ class goto_symex_is_constantt : public is_constantt
153
153
*/
154
154
return false ;
155
155
}
156
+ else if (expr.id () == ID_if)
157
+ {
158
+ const if_exprt &if_expr = to_if_expr (expr);
159
+ if (
160
+ if_expr.true_case ().id () == ID_if || if_expr.false_case ().id () == ID_if)
161
+ return false ;
162
+ }
163
+ else if (expr.id () == ID_nondet_symbol)
164
+ return true ;
165
+ else if (expr.id () == ID_symbol)
166
+ {
167
+ const irep_idt &obj_identifier = to_ssa_expr (expr).get_object_name ();
168
+ return obj_identifier == " goto_symex::\\ guard" ;
169
+ }
156
170
157
171
return is_constantt::is_constant (expr);
158
172
}
Original file line number Diff line number Diff line change @@ -241,7 +241,9 @@ bool is_constantt::is_constant(const exprt &expr) const
241
241
expr.id () == ID_with || expr.id () == ID_struct || expr.id () == ID_union ||
242
242
// byte_update works, byte_extract may be out-of-bounds
243
243
expr.id () == ID_byte_update_big_endian ||
244
- expr.id () == ID_byte_update_little_endian)
244
+ expr.id () == ID_byte_update_little_endian ||
245
+ // member works, index may be out-of-bounds
246
+ expr.id () == ID_member || expr.id () == ID_if)
245
247
{
246
248
return std::all_of (
247
249
expr.operands ().begin (), expr.operands ().end (), [this ](const exprt &e) {
@@ -276,8 +278,12 @@ bool is_constantt::is_constant_address_of(const exprt &expr) const
276
278
277
279
return is_constant (deref.pointer ());
278
280
}
279
- else if (expr.id () == ID_string_constant)
281
+ else if (
282
+ expr.id () == ID_string_constant || expr.id () == ID_array ||
283
+ expr.id () == ID_struct || expr.id () == ID_union)
284
+ {
280
285
return true ;
286
+ }
281
287
282
288
return false ;
283
289
}
You can’t perform that action at this time.
0 commit comments