From lukas.stadler at oracle.com  Thu Aug 24 17:15:16 2017
From: lukas.stadler at oracle.com (Lukas Stadler)
Date: Thu, 24 Aug 2017 17:15:16 +0200
Subject: [Rd] loop compilation problem
Message-ID: <8EA1A94F-EB30-4AE0-A399-C9F73BC33EB5@oracle.com>

Hi!

We?ve seen a problem with the compiler in specific cases of matrix updates:

> { m <- matrix(1:4, 2) ; z <- 0; for(i in 1) { m[z <- z + 1,z <- z + 1] <- 99; } ; m }
     [,1] [,2]
[1,]    1    3
[2,]    2   99

Here, it modifies element [2,2], which is unexpected.
It behaves correct without the loop:

> { m <- matrix(1:4, 2) ; z <- 0; m[z <- z + 1,z <- z + 1] <- 99 ; m }
     [,1] [,2]
[1,]    1   99
[2,]    2    4

? and without the jit:

> enableJIT(0)
[1] 3
> { m <- matrix(1:4, 2) ; z <- 0; for(i in 1) { m[z <- z + 1,z <- z + 1] <- 99; } ; m }
     [,1] [,2]
[1,]    1   99
[2,]    2    4

I checked with "R Under development (unstable) (2017-08-23 r73116)?, and the problem is still there.

- Lukas


[Rd] loop compilation problem
Lukas Stadler