When answering this question, I came across this code...
#include <iostream>
int main()
{
int const income = 0;
std::cout << "I'm sorry your income is: " < income; // this is line 6
}
...which contains a typo. The second (intended) <<
operator on line 6 has been accidentally written as a <
.
That aside, compiling the code using GCC 4.3.4 or 4.4.3 results in a warning:
prog.cpp: In function ‘int main()’:
prog.cpp:6: warning: right-hand operand of comma has no effect
My question: why is that particular warning produced? Which comma operator is it referring to?
NOTE: I'm not advocating deliberately using a single <
in a cout
statement. I merely stumbled across this warning while trying to figure out an answer to the other question I've linked to, and am curious as to why the compiler generates it.
void * v() { return 0; } ... v() < 0;
- I'd say it's a bug in gcc. – Tiber