The accidental assignment and operator precedence

Question | Jul 27, 2016 | nextptr 

It is quite common for C++ programmers to come across accidental usage of assignment operator (=) where equality comparison (==) is intended. Here is an interesting example of that:

int foo(int cond) {
  // notice the = operator in left of ||
  if(cond = 0 || cond == 1)
      return cond;
  return -1;
}

What will be the result of calling foo as:

std::cout << foo(1);