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

Indeed, another problem is that we have no tools, other than very imperfect linters/compiler warnings, to identify aliasing violations. Even today I don't think sanitizers can catch most cases.


More often than not when I realise that I am violating strict aliasing it is because I am doing something that I want to do and the language is not going to let me. Much hand wringing, language lawyering and time wasting typically follows.


That is understood.

However, it is generally too hard (in C and C++) for compilers to tell whether you were wanting to do the thing at any one particular place.

So compilers have two options: Assume that you never do the thing, or always assume that you don't do the thing.

The former is often better for performance in practice, and it's true most of the time, so here we are.

As has been pointed out elsewhere, one of the strengths of Rust is that it shifts how pointers (references) work and allows the compiler to more often know for certain that you don't do the thing, without making assumptions.




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

Search: