Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The mental model I'm seeing there is simple - the compiler is allowed to assume a 'contract' of "The caller will ensure that the function is called only such argument values that the undefined condition is never reached".

In this particular case, the 'contract' and the actual code imply that "The only allowed values of 'int v' are those that actually are found in the table"; for those values the function correctly returns true; and for all the possible 'illegal' arguments any and every possible behavior would be correct.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: