File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -3928,7 +3928,22 @@ static String cproverFormatArgument(Object obj) {
39283928 builder .append ((char ) (longValue >> 32 & 0xFFFF ));
39293929 builder .append ((char ) (longValue >> 16 & 0xFFFF ));
39303930 builder .append ((char ) (longValue & 0xFFFF ));
3931- return builder .toString ();
3931+ String str = builder .toString ();
3932+
3933+ // These redundant constraints are necessary in case the string solver
3934+ // decides not to propagate the constraints for the concatenation above.
3935+ // This happens, for instance, when the method under test calls
3936+ // String.format on an integer and returns the length. In this case,
3937+ // only the constraints for the length are propagated in the
3938+ // dependency graph, but the length of the formatted string depends
3939+ // on the value of the integer, whose conversion is not normally
3940+ // propagated in the dependency graph.
3941+ CProver .assume (str .charAt (0 ) == (char ) (longValue >> 48 & 0xFFFF ));
3942+ CProver .assume (str .charAt (1 ) == (char ) (longValue >> 32 & 0xFFFF ));
3943+ CProver .assume (str .charAt (2 ) == (char ) (longValue >> 16 & 0xFFFF ));
3944+ CProver .assume (str .charAt (3 ) == (char ) (longValue & 0xFFFF ));
3945+
3946+ return str ;
39323947 }
39333948
39343949 /**
You can’t perform that action at this time.
0 commit comments