When answering this question, I came across this code...
#include
int main()
{
int const income = 0;
std::cout << \"I\'m sorr
I think they just forgot to change the warning text
int main() {
1, 2;
}
prog.cpp:2: warning: left-hand operand of comma has no effect
prog.cpp:2: warning: right-hand operand of comma has no effect
The expr, expr
operator evaluates the left operand, then evaluates the right operand and yields the result of the right operand's evaluation. If the right operand has no effect and its value is not used, it's probably a bug in the program.
Now they just abused the above warning text to warn for other binary operators, it seems.
Your given program doesn't produce that warning for me with MSVC2010, it only produces
warning C4552: '<' : operator has no effect; expected operator with side-effect
As that should be a <<
before income;
.
(Note: Ideone doesn't produce a warning at all.)