Why is this piece of C code valid?
int main() {
int x = 0, y = 0;
x * y; // See this?!
}
The most ubiquitous examples that explain the need for back-tracking in parser often shows this. And then goes on to say that depending on what x
is, the meaning of *
will change. For some time, I believed it was just a way of explaining until I compiled it and found to my surprise, it compiles and works!
Why is a multiplication without an LHS valid in C and what is it used for?
Edit This confusion is because, the same piece of code won't compile in Java. It seems Java compiler tries to prevent operations without LHS.