I am running this code on Visual Studio 2015 Update 1 and I am getting really weird access violation error at the place denoted below. If I simplify the expression to something like int mid = (max - min) / 2;
the code works fine.
#include <experimental/generator>
std::experimental::generator<int> range(int min, int max)
{
int mid = min + (max - min) / 2; // write access violation
yield mid;
}
int main()
{
for (auto x : range(10, 20)) { }
}
Does anyone know what might be the problem? I am suspecting that it might be a compiler bug.
This is a confirmed bug in Visual Studio 2015 Update 1: https://connect.microsoft.com/VisualStudio/feedback/details/2337518/std-experimental-generator-write-access-violation
It will be reportedly fixed in Update 2