The behaviour of using index and ++index inside the same assignment is unspecified in C++. You just can't just do that: write arr[index] = index + 1 and increment your variable after that. For that matter, with my C++ compiler on my machine I see arr[0] = 1, and arr[1] is untouched.