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

> dereferencing an invalid pointer is undefined behaviour, which means the compiler is allowed to assume it never happens;

Sure, but it didn't have to be like this. They could have said it is unspecified wihout allowing the compiler to assume it doesn't happen.

Would C have been better if the spec was different?



That's not what's happening. Because it's unspecified transforms that are safe in the absence of that behavior are safe to apply since they preserve the semantics.

Even something like register allocation requires knowledge of what pointers point to.




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

Search: