From: | cross@spitfire.i.gajendra.net |
Newsgroups: | comp.compilers |
Date: | Fri, 16 May 2025 15:42:33 -0000 |
Organization: | Compilers Central |
References: | 25-05-004 25-05-005 25-05-006 |
Injection-Info: | gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="92960"; mail-complaints-to="abuse@iecc.com" |
Keywords: | Rust |
Posted-Date: | 16 May 2025 13:48:02 EDT |
In article 25-05-006, <arnold@freefriends.org> wrote:
>In article 25-05-005,
>Derek <derek-nospam@shape-of-code.com> wrote:
>>I suspect that the same is happening with Rust. If so, how does using
>>Rust make the code safer than using C without any checking switched
>>on?
>
>Rust catches many problems at compile time. I am not at all a Rust
>expert, or even a novice, but I don't think Rust does runtime
>bounds checking, since it relies on compiler analysis instead.
Other way 'round, mostly. Array bounds checking is performed at
runtime, but if the compiler can prove that the bounds check is
superfluous (trivial example: the index is the constant 0 for a
non-empty array) then it can elide the code that does the check.
Someone has put together a nice document demonstrating some of
the more useful techniques:
https://github.com/Shnatsel/bounds-check-cookbook/
- Dan C.
Return to the
comp.compilers page.
Search the
comp.compilers archives again.