@@ -419,7 +419,9 @@ exprt string_constraint_generatort::add_axioms_for_parse_int(
419
419
PRECONDITION (f.arguments ().size ()==1 || f.arguments ().size ()==2 );
420
420
string_exprt str=get_string_expr (f.arguments ()[0 ]);
421
421
const exprt radix=
422
- f.arguments ().size ()==1 ?from_integer (10 , f.type ()):f.arguments ()[1 ];
422
+ f.arguments ().size ()==1 ?
423
+ static_cast <exprt>(from_integer (10 , f.type ())):
424
+ static_cast <exprt>(typecast_exprt (f.arguments ()[1 ], f.type ()));
423
425
424
426
const typet &type=f.type ();
425
427
symbol_exprt i=fresh_symbol (" parsed_int" , type);
@@ -436,21 +438,23 @@ exprt string_constraint_generatort::add_axioms_for_parse_int(
436
438
not_exprt (or_exprt (starts_with_minus, starts_with_plus));
437
439
438
440
// / TODO: we should throw an exception when this does not hold:
439
- exprt correct=add_axioms_for_correct_number_format (str, radix);
441
+ const std::size_t max_string_length=40 ;
442
+ const exprt &correct=add_axioms_for_correct_number_format (
443
+ str, radix, max_string_length);
440
444
axioms.push_back (correct);
441
445
442
446
// / TODO(OJones): size should depend on the radix
443
447
// / TODO(OJones): we should deal with overflow properly
444
- for (unsigned size=1 ; size<=10 ; size++)
448
+ for (std:: size_t size=1 ; size<=max_string_length ; size++)
445
449
{
446
450
exprt sum=from_integer (0 , type);
447
451
exprt first_value=get_numeric_value_from_character (chr, char_type, type);
448
452
equal_exprt premise=str.axiom_for_has_length (size);
449
453
450
- for (unsigned j=1 ; j<size; j++)
454
+ for (std:: size_t j=1 ; j<size; j++)
451
455
{
452
456
mult_exprt radix_sum (sum, radix);
453
- if (j>=9 )
457
+ if (j>=max_string_length- 1 )
454
458
{
455
459
// We have to be careful about overflows
456
460
div_exprt div (sum, radix);
@@ -463,7 +467,7 @@ exprt string_constraint_generatort::add_axioms_for_parse_int(
463
467
get_numeric_value_from_character (str[j], char_type, type));
464
468
465
469
mult_exprt first (first_value, radix);
466
- if (j>=9 )
470
+ if (j>=max_string_length- 1 )
467
471
{
468
472
// We have to be careful about overflows
469
473
div_exprt div_first (first, radix);
0 commit comments