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

You’d think that C could do any appropriate optimizations as well as D, since the C compiler (in theory) should know whether there can exist (in any given program) any writeable pointers to the same value or if there only can exist pointers to const.


Only inside the same compilation unit.


Doing it across the whole compilation requires LTCG, but that does exist as well. It just makes incremental builds a pain with large binaries.


Pointer arithmetic would surely make all value mutable. Or even simple array access.


Yes, but the compiler should know if there is any pointer arithmetic present in the code, and whether any such pointer arithmetic could, possibly, result in a pointer pointing to the const data.


If you point to writable memory (Not all programs reside in ram.)




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

Search: