Under Stata 15.1, I experienced an odd behavior in a program that I have written. I first created a Mata view on a variable in the data set and subsequently run a fixed-effects regression with xtreg. The effect was that the content of the Mata view has changed although the data set itself remained unchanged.
Code:
program define bugtest
    version 13
    syntax varlist [if]
    marksample touse
    gettoken depvar indepvars : varlist

    mata: st_view(y = ., ., "`depvar'", "`touse'")
    mata: y
    quietly xtreg `depvar' `indepvars', fe
    mata: y
end

bugtest n w if id <= 2
The output is:
Code:
                  1
     +---------------+
   1 |  1.617604494  |
   2 |  1.722766638  |
   3 |  1.612433434  |
   4 |  1.550748944  |
   5 |  1.409278154  |
   6 |   1.15246892  |
   7 |  1.077048182  |
   8 |    4.2671628  |
   9 |  4.257638931  |
  10 |    4.2615242  |
  11 |  4.277096748  |
  12 |  4.299853802  |
  13 |  4.282468796  |
  14 |  4.227096558  |
     +---------------+
                  1
     +---------------+
   1 |   95.7071991  |
   2 |  97.35690308  |
   3 |  99.60829926  |
   4 |  100.5501022  |
   5 |  99.55809784  |
   6 |  98.61509705  |
   7 |   100.030098  |
   8 |   95.7071991  |
   9 |  97.35690308  |
  10 |  99.60829926  |
  11 |  100.5501022  |
  12 |  99.55809784  |
  13 |  98.61509705  |
  14 |   100.030098  |
     +---------------+
The second call to the Mata view gave me the content of the variable indoutpt instead of the variable n, i.e. the variable index was shifted by -1.

This problem does not occur if I use the random-effects estimator (i.e. xtreg without option fe) and it also does not occur if I replace version 13 by version 14 (or version 15) in the first line of the program. Interestingly, the problem does not occur either under Stata 14 even if I keep the version 13 statement.

Can anyone replicate this problem?