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

The standard library thing is interesting. Modern compilers actually understand that stuff a lot. I don't think they'll reach into the implementation, but they understand the guaranteed semantics. For example, they know that this is undefined behavior:

    free(ptr);
    printf("after free, it contains %d\n", *ptr);
And the nasal demons shall flow freely. The compiler will certainly know that there's a NULL check in there. However, the smarts are different enough that it will also know not to warn you about it. So, yes, this is an example that won't happen in reality, although there's no reason it couldn't.


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

Search: