AAU Student Projects - visit Aalborg University's student projects portal
A master thesis from Aalborg University

Enforcing Memory Safety in Modern C++ Through a Safe Subset and Static Analysis

Author(s)

Term

4. term

Education

Publication year

2025

Submitted on

2025-05-29

Pages

21 pages

Abstract

This thesis investigates how memory safety can be enforced in C++ by defining a conservative, safe subset of the language and applying static analysis. While modern C++ offers features and guidelines that support safer programming practices, these are not enforced by compilers and remain optional. To address this, the project introduces a static analysis, that detects lifetime violations and enforces exclusive access to mutable resources, similar to Rust’s borrow checker and lifetime model. This analysis is accompanied by a proof-of-concept implementation, CPlusPlusty, as a Clang plugin. The approach restricts unsafe constructs by default and uses an over-approximating analysis to ensure soundness. CPlusPlusty demonstrates that memory safety guarantees can be retrofitted onto modern C++ code. The results suggest that such guarantees can be achieved without major language extensions or alternative frontends, merely by applying static analysis and enforcing safer usage patterns within standard C++.

Keywords

Documents


Colophon: This page is part of the AAU Student Projects portal, which is run by Aalborg University. Here, you can find and download publicly available bachelor's theses and master's projects from across the university dating from 2008 onwards. Student projects from before 2008 are available in printed form at Aalborg University Library.

If you have any questions about AAU Student Projects or the research registration, dissemination and analysis at Aalborg University, please feel free to contact the VBN team. You can also find more information in the AAU Student Projects FAQs.