Groups | Search | Server Info | Keyboard shortcuts | Login | Register


Groups > comp.compilers > #3651

Re: Paper: PR2: Peephole Raw Pointer Rewriting with LLMs for Translating C to Safer Rust

Path csiph.com!weretis.net!feeder9.news.weretis.net!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end
From anton@mips.complang.tuwien.ac.at
Newsgroups comp.compilers
Subject Re: Paper: PR2: Peephole Raw Pointer Rewriting with LLMs for Translating C to Safer Rust
Date Thu, 15 May 2025 07:48:12 +0000
Organization Compilers Central
Sender johnl%iecc.com
Approved comp.compilers@iecc.com
Message-ID <25-05-008@comp.compilers> (permalink)
References <25-05-004@comp.compilers> <25-05-005@comp.compilers> <25-05-006@comp.compilers> <25-05-007@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="39138"; mail-complaints-to="abuse@iecc.com"
Keywords Rust, optimize, comment
Posted-Date 15 May 2025 10:48:09 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:3651

Show key headers only | View raw


Kaz Kylheku <643-408-1753@kylheku.com> writes:
>On 2025-05-14, arnold@freefriends.org <arnold@freefriends.org> wrote:
>> [Rust] relies on compiler analysis instead.
>
>How would it be safe if you could write a Rust program that asks the
>user to input a random decimal number, and then uses it an index to
>access an array, without any check?

I don't know if Rust does it this way, but it could reject a program
that does a[i] if it cannot prove that i is an allowed index for a.
For your example, a program like this would be rejected:

input i
print a[i]

(using what little I remember from BASIC syntax because I don't know the Rust
syntax:-).  If you want the compiler to accept it, you could write

input i
if i < length[a] then
  print a[i]
else
  print "index out of range"
endif

- anton
--
M. Anton Ertl
anton@mips.complang.tuwien.ac.at
http://www.complang.tuwien.ac.at/anton/
[I believe that Rust does runtime checks unless it can prove at compile time that they're not needed.
It has a fancy exception system to catch access violations. -John]

Back to comp.compilers | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Paper: PR2: Peephole Raw Pointer Rewriting with LLMs for Translating C to Safer Rust John R Levine <johnl@taugh.com> - 2025-05-09 12:27 -0400
  Re: Paper: PR2: Peephole Raw Pointer Rewriting with LLMs for Translating C to Safer Rust Derek <derek-nospam@shape-of-code.com> - 2025-05-13 21:30 +0100
    Re: Paper: PR2: Peephole Raw Pointer Rewriting with LLMs for Translating C to Safer Rust arnold@freefriends.org - 2025-05-14 08:21 +0000
      Re: Paper: PR2: Peephole Raw Pointer Rewriting with LLMs for Translating C to Safer Rust Kaz Kylheku <643-408-1753@kylheku.com> - 2025-05-14 20:01 +0000
        Re: Paper: PR2: Peephole Raw Pointer Rewriting with LLMs for Translating C to Safer Rust anton@mips.complang.tuwien.ac.at - 2025-05-15 07:48 +0000
      Re: Paper: PR2: Peephole Raw Pointer Rewriting with LLMs for Translating C to Safer Rust George Neuner <gneuner2@comcast.net> - 2025-05-15 11:52 -0400
      Re: Paper: PR2: Peephole Raw Pointer Rewriting with LLMs for Translating C to Safer Rust cross@spitfire.i.gajendra.net - 2025-05-16 15:42 +0000
        Re: Paper: PR2: Peephole Raw Pointer Rewriting with LLMs for Translating C to Safer Rust Kaz Kylheku <643-408-1753@kylheku.com> - 2025-05-16 17:57 +0000

csiph-web