3 ms·
The reason for casts between data and function pointers is not about separate data and code spaces (that much), but about: 1) supporting architectures where co
by dfox 9y ago
The reason for casts between data and function pointers is not about separate data and code spaces (that much), but about:
1) supporting architectures where code and data pointers have different size. One might think of various Hardvard architecture microcontrollers, but most C memory models for real mode x86 have this feature.
2) environments where code pointers essentially convey capability and thus have to be created by the OS in order to be usable (this typically involves indirect call instructions reading from some part of memory that is not otherwise accessible to user space at all)