Skip to content

Commit

Permalink
Bug fix R_integer_plus with overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
TDiazT committed Jun 12, 2018
1 parent f39f944 commit a8cf22d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/features/FArithmetic.v
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Definition R_allocOrReuseVector S s1 s2 type n :=
Definition R_integer_plus x y :=
ifb x = NA_INTEGER \/ y = NA_INTEGER then NA_INTEGER
else
ifb (y < 0 /\ x > R_INT_MAX - y)%Z \/ (y > 0 /\ x < R_INT_MIN - y)%Z then
ifb (y > 0 /\ x > R_INT_MAX - y)%Z \/ (y < 0 /\ x < R_INT_MIN - y)%Z then
(* A warning has been formalised out here. *)
NA_INTEGER
else (x + y)%Z.
Expand Down
11 changes: 11 additions & 0 deletions tests/do_for.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# @line
# do_for tests

for(1 in 1:10) 1
for("x" in 1:10) 1

f<-function() { x<-1 ; for(i in 1:10) { x<-x+1 } ; x } ; f(); f()
f<-function(r) { x<-0 ; for(i in r) { x<-x+i } ; x } ; f(c(1,2,3,4,5)) ; f(1:10)
f<-function(r) { x<-0 ; for(i in r) { x<-x+i } ; x } ; f(1:10) ; f(c(1,2,3,4,5))
f<-function(i) { if (i<=1) {1} else {r<-i; for(j in 2:(i-1)) {r=r*j}; r} }; f(10)
x<-1 ; for(i in 1:10) { x<-x+1 } ; x

0 comments on commit a8cf22d

Please sign in to comment.