> Last week I spent 4 hours trying to find what turned out to be a missing = because C++ will not complain, but will behave very differently, when = is confused with ==.
Uh, all reasonable compilers warn about ambiguous use of = as a truth value.
$ g++ -Wall -c a.cc
a.cc: In function βint foo(int, int)β:
a.cc:2:12: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
$ clang++ -Wall -c a.cc # output is colored
a.cc:2:9: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]
if (x = y) return 0;
~~^~~
a.cc:2:9: note: place parentheses around the assignment to silence this warning
if (x = y) return 0;
^
( )
a.cc:2:9: note: use '==' to turn this assignment into an equality comparison
if (x = y) return 0;
^
==
1 warning generated.
Uh, all reasonable compilers warn about ambiguous use of = as a truth value.