Path: csiph.com!eternal-september.org!feeder3.eternal-september.org!news.iecc.com!.POSTED.news.iecc.com!nerds-end From: Kaz Kylheku <643-408-1753@kylheku.com> Newsgroups: comp.compilers Subject: Re: Paper: PR2: Peephole Raw Pointer Rewriting with LLMs for Translating C to Safer Rust Date: Fri, 16 May 2025 17:57:35 -0000 Organization: Compilers Central Sender: johnl%iecc.com Approved: comp.compilers@iecc.com Message-ID: <25-05-012@comp.compilers> References: <25-05-004@comp.compilers> <25-05-005@comp.compilers> <25-05-006@comp.compilers> <25-05-011@comp.compilers> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="72396"; mail-complaints-to="abuse@iecc.com" Keywords: Rust, optimize Posted-Date: 16 May 2025 18:06:51 EDT X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com Xref: csiph.com comp.compilers:3655 On 2025-05-16, cross@spitfire.i.gajendra.net wrote: > In article <25-05-006@comp.compilers>, wrote: >>In article <25-05-005@comp.compilers>, >>Derek 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. The logic doesn't even have to be specific to array bounds checking. If we know that "i" is in the range 0 to 9, then "if (i < 10) S;" is dead code, whether appearing literally that way in the source code, or whether such a test is generated for an array access. -- TXR Programming Language: http://nongnu.org/txr Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal Mastodon: @Kazinator@mstdn.ca