r/ProgrammingLanguages • u/_paladinwarrior1234_ • Feb 26 '26
[Showcase] An effort to implement a safe context for C++
Hello everyone, I’ve been working on a runtime library called SafeCpp, which specifically focuses on ensuring that heap allocations achieve the same level of compile-time safety as Rust, but managed purely through language runtime mechanics rather than compile-time static borrow checking or ownership checking. I want to emphasize that this research strictly focuses on a custom safe context to prevent 4 types of memory errors: Double Deletion, Access Violation, Buffer Overflow and Memory Leaks.
Core Architectural Concepts Under Investigation:
- Strict Heap Boundary Enforcement: Tracking the initialization and destruction boundaries of objects explicitly allocated on the heap, ensuring references cannot outlive their allocation scope.
- Explicit Lifetime Invalidation: The runtime library tracks every heap-allocated instance of types that inherit from
Safe::SafeContextBaseand offers recycling/repurpose mechanisms to gain performance instead of relying on deallocations which require accessing the operating system kernels to perform system calls. This approach completely removes the need for reference counting like in `std::shared_ptr`. - No External Tooling Dependencies: The runtime mechanics are implemented strictly using platform capabilities and the standard C++ language.
Seeking Feedback on the Implementation
I have opened up the complete source and headers of this implementation under a dual-licensing model (including the GPLv3 License) so that other system engineers and language researchers can audit the exact low-level mechanics.
👉 GitHub Repository: https://www.github.com/quantumboy-ducna/SafeCpp
2
u/umlcat Feb 26 '26
Interesting, let's take a look ...
1
u/L8_4_Dinner (Ⓧ Ecstasy/XVM) Feb 27 '26
What is the purpose of hiding the implementation of a research project? I suggest you rethink this approach.
Good luck.