Warning C6395

%variable% has unsequenced reads and/or writes before C++17; changing the language standard might change the behavior of the code.

Remarks

C++17 made the evaluation order of certain expressions stricter. MSVC complied, which changed the evaluation order for some expressions. Thus, changing the language version might change the observable behavior of the program. This check diagnoses some of the cases where the meaning of the code changes due to switching language versions.

Code analysis name: EVAL_ORDER_CHANGE

Example

void foo(int* a, int i)
{
    a[++i] = i; // Warning: 'i' has unsequenced reads and/or writes before C++17; changing the language standard might change the behavior of the code
}

To solve this problem, separate the side effects from the rest of the expression to make the evaluation order well defined:

void foo(int* a, int i)
{
    ++i;
    a[i] = i; // No warning.
}