Semantic errors
- by gautam kumar
Can semantic errors be detected by the compiler or not? If not when do the errors get detected?
As far as I know semantic errors are those errors which result from the expressions involving operators with incorrect number/type of operands.
For example:
n3=n1*n2;//n1 is integer, n2 is a string, n3 is an integer
The above statement is semantically incorrect.
But while reading C Primer Plus by Stephen Prata I found the following statement
The compiler does not detect semantic errors, because they don't violate C rules. The compiler has no way of divining your true intentions. That leaves it to you to find these kinds of errors. One way is to compare what a program does to what you expected it to do.
If not the compiler, who detects those errors?
Am I missing something?