Sujet : Re: Computer architects leaving Intel...
De : david.brown (at) *nospam* hesbynett.no (David Brown)
Groupes : comp.archDate : 16. Sep 2024, 19:08:42
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vc9s7b$2vus6$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13
User-Agent : Mozilla Thunderbird
On 16/09/2024 19:57, MitchAlsup1 wrote:
On Mon, 16 Sep 2024 13:04:02 +0000, Michael S wrote:
On Mon, 16 Sep 2024 14:48:50 +0200
David Brown <david.brown@hesbynett.no> wrote:
It's not less efficient. usize in Rust is approximately the same as
size_t in C. With one exception that usize overflow panics under debug
build.
One can and should argue that::
#p++;
should panic if p++ crosses an address space boundary (user->OS, or
OS->HyperVisor,...) as no array is allowed to cross such a boundary.
That is outside the scope of C, which has no concept of address space boundaries, or even an OS (other than as something that makes the standard library functions work).
Of course it is perfectly fine if, on any given implementation, trying to access through an invalid pointer (including beyond the end of an array) results in some kind of panic, crash, OS exception, or other error. Those are all valid for UB. But it is not possible or practical to specify or require such action from a language. At best, a language could say that some kind of run-time error handling must be supported and that it is triggered by certain kinds of out of bounds accesses (defined by the language, not by address space boundaries). Even then, you are not going to be able to detect all invalid pointer uses while maintaining low-level and efficient direct pointer usage.