This error has nothing to do with the compiler. Whether it's C or Java, as long as it does not violate the language syntax and semantic, the code will compile.
What you have is a logical error which could be detected by the language run-time environment, e.g. JVM, which what C lacks.