Home Ask Login Register

Developers Planet

Your answer is one click away!

Огњен Шобајић February 2016

std::experimental::generator write access violation

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.


Огњен Шобајић February 2016

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

Post Status

Asked in February 2016
Viewed 1,890 times
Voted 9
Answered 1 times


Leave an answer

Quote of the day: live life