mlsanityData to 7 Oct 2026

Raw Pointer Rewriting with LLMs for Translating C to Safer Rust

arXiv 2505.04852 ↗First posted 7 May 2025cs.SE cs.AI cs.PLcited by 4

Not on the map. Why?

Abstract (arXiv)

There has been a growing interest in translating C code to Rust due to Rust's robust memory and thread safety guarantees. Tools such as C2RUST enable syntax-guided transpilation from C to semantically equivalent Rust code. However, the resulting Rust programs often rely heavily on unsafe constructs, particularly raw pointers, which undermines Rust's safety guarantees. This paper aims to improve the memory safety of Rust programs generated by C2RUST by eliminating raw pointers. Specifically, we propose a raw pointer rewriting technique that lifts raw pointers in individual functions to appropriate Rust data structures. Technically, PR2 employs decision-tree-based prompting to guide the pointer lifting process. It also leverages code change analysis to guide the repair of errors introduced during rewriting, effectively addressing errors encountered during compilation and test case execution. We implement PR2 and evaluate it using gpt-4o-mini on 28 real-world C projects. It is shown that PR2 successfully eliminates 18.57% of local raw pointers across these projects, significantly enhancing the safety of the translated Rust code. On average, PR2 completes the transformation of a project in 5.02 hours, at a cost of 1.13.

Key facts. Cited by 4 papers in the map (data through 7 Oct 2026). Builds on 13 of its 32 references that are in the map. First posted on arXiv 7 May 2025.

Builds on

13 of 32 references.

References · 13

  1. 2024RepairAgent: An Autonomous, LLM-Based Agent for Program Repaircited by 225
  2. 2023Using an LLM to Help With Code Understandingcited by 222
  3. 2023Keep the Conversation Going: Fixing 162 out of 337 bugs for 0.42 each using ChatGPTcited by 125
  4. 2024Exploring and Unleashing the Power of Large Language Models in Automated Code Translationcited by 57
  5. 2024A Case Study of LLM for Automated Vulnerability Repair: Assessing Impact of Reasoning and Patch Validation Feedbackcited by 22
  6. 2023CoTran: An LLM-based Code Translator using Reinforcement Learning with Feedback from Compiler and Symbolic Executioncited by 21
  7. 2024VERT: Verified Equivalent Rust Transpilation with Large Language Models as Few-Shot Learnerscited by 20
  8. 2024Rectifier: Code Translation with Corrector via LLMscited by 20
  9. 2023Ownership guided C to Rust translationcited by 13
  10. 2025Validating Network Protocol Parsers with Traceable RFC Document Interpretationcited by 7
  11. 2024DiffSpec: Differential Testing with LLMs using Natural Language Specifications and Code Artifactscited by 5
  12. 2025Large Language Models for Validating Network Protocol Parserscited by 5
1 more
  1. 2021Constraint-based Relational Verificationcited by 2

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2025: 1; 2026: 3.

4 papers.