Hacker News new | ask | show | jobs
by marginalia_nu 1169 days ago
There's actually a fairly big difference with the context of the language preventing the error.

If the code is wrong as in undefined behavior, then the compiler can and maybe should try to prevent it. If the programmer is wrong about the code, then the compiler can't and definitely shouldn't try to prevent it.

In short, the compiler can't prevent this

  int is_empty(char* s) {
    return strlen(s) > 10;
  }
The compiler maybe could prevent this:

  is_empty(NULL);