Re:The Tao of Programming
by kazinator on Thursday September 28, 2023 @03:25PM
(#37694471)
The thing is, the pointers that hardware understands are safer than C pointers.
C pointers have undefined behaviors which are not found in the machine language.
For anything that can go wrong with C pointers (and other types) in the abstract, there is some computer out there where it is an issue. That computer is usually in a museum; it's not one that understands a popular instruction set.
The problem is that the omissions in the definition of behavior done because of portability across machines turn into an optimization hint. Things that were once left undefined because they worked in reliable, but machine-spcific ways became booby traps.
To be sure your code will work with optimizations, you have to write it as if it had to be portable to machines you don't care about.
You don't have that problem in assembly language, or not on the same scale. You sometimes worry about different members of the same instruction set family, and that's about it.
C pointers have undefined behaviors which are not found in the machine language.
For anything that can go wrong with C pointers (and other types) in the abstract, there is some computer out there where it is an issue. That computer is usually in a museum; it's not one that understands a popular instruction set.
The problem is that the omissions in the definition of behavior done because of portability across machines turn into an optimization hint. Things that were once left undefined because they worked in reliable, but machine-spcific ways became booby traps.
To be sure your code will work with optimizations, you have to write it as if it had to be portable to machines you don't care about.
You don't have that problem in assembly language, or not on the same scale. You sometimes worry about different members of the same instruction set family, and that's about it.