Lucian Popescu, Francisco Gouveia, Henrique Preto, João Silveira, Dmytro Hrybenko, José Fragoso Santos, Nuno P. Lopes
About 70% of security vulnerabilities in widely deployed software originate from memory-safety bugs in languages such as C and C++. Despite decades of investment in mitigations, from static analysis and sanitizers to hardware isolation, attackers continue to exploit unsafe memory operations. A promising long-term solution is to migrate existing C++ codebases to memory-safe languages such as Rust, but doing so manually is prohibitively expensive and error-prone.
In this paper, we present Cpp2Rust, the first system capable of translating C++ programs into functionally equivalent and memory-safe Rust code automatically. By trading some performance for security, Cpp2Rust addresses the fundamental mismatch between C++'s unrestricted aliasing and Rust's ownership model by inserting runtime-enforced ownership and mutability checks, ensuring safety while preserving semantics. To mitigate the performance overhead of dynamic checks, we developed a suite of source-to-source optimizations for Rust code that eliminate redundant ownership operations and recover much of the lost performance.
We evaluate Cpp2Rust on two real-world C++ programs, totaling 13k lines of code: WOFF2, a font compression library, and Brunsli, a JPEG lossless compression library. Cpp2Rust achieves full memory safety with only a 2% performance penalty on WOFF2 compression, while being 6× slower on Brunsli due to heavy usage of pointer arithmetic. These results demonstrate that automated, semantics-preserving translation from C++ to safe Rust is practical for some safety-critical applications, offering a viable path toward eliminating memory-safety vulnerabilities in legacy systems.
L. Popescu, F. Gouveia, H. Preto, J. Silveira, D. Hrybenko, J. F. Santos, N. P. Lopes. Cpp2Rust: Automatic Translation of C++ to Safe Rust. Proc. of the ACM on Programming Languages, Volume 10 Issue PLDI, June 2026.
@article{cpp2rust-pldi26,
title = {{Cpp2Rust}: Automatic Translation of C++ to Safe Rust},
author = {Lucian Popescu and Francisco Gouveia and Henrique Preto and Jo{\~a}o Silveira and Dmytro Hrybenko and Jos\'{e} Fragoso Santos and Nuno P. Lopes},
journal = {Proc. of the ACM on Programming Languages},
volume = {10},
articleno = {188},
number = {PLDI},
publisher = {ACM},
doi = {10.1145/3808266},
month = jun,
year = 2026
}
© The Authors, 2026. Licensed under the Creative Commons Attribution 4.0 International License.