> I think this is a bug. Either i should be const during loop iteration, > or an additional temporary should be manufactured. > > It is always possible to get the above behavior using a for loop. > foreach should be sane. I agree, you'd expect it to be passed by value. As mentioned reference must be stated explicitly. foreach(ref i...)