-
Notifications
You must be signed in to change notification settings - Fork 0
Cpp Support
Derek Snider edited this page Jul 23, 2026
·
1 revision
madc is a C/C++ dialect: C++ features are lowered Cfront-style to plain C11
inside the compiler, then compiled by the same MIR backend as everything else.
That means C++ programs work in every mode — JIT, native executables,
--emit=c11 C source output — with no separate C++ runtime.
The C++ surface has grown far beyond the early days. What works today:
- Constructors, destructors, copy constructors — including the implicit memberwise copy constructor for classes that never declared one (nested members with their own copy constructors are deep-copied correctly)
- Methods (including
constmethods),this, member access control - Operator overloading — arithmetic, comparison, subscript, and the C++20
three-way comparison
<=>(spaceship) with synthesized relationals - References (
T&) as parameters, returns, and members -
new/deletewith constructor/destructor invocation - RAII — destructors run at every scope exit, return, and exception unwind
- Single, multiple, and virtual inheritance with the Itanium C++ ABI layout — thunks, virtual bases constructed exactly once
- Virtual functions and virtual destructors (complete D1/D0 semantics)
- RTTI and
dynamic_cast
- Class templates, function templates, and member function templates with real monomorphization — each instantiation compiles to concrete native code
- The pattern is parsed once and instantiated by substitution (the same model g++ uses), so heavy template code stays fast to compile
- Template-id casts (
(Box<int>)x), alias templates, default arguments
-
try/catch/throwwith type-dispatched catch clauses, lowered to portable C (setjmp/longjmp) so they work in every output mode
-
std::string,std::stringstream,cout/cin/cerrare real libstdc++ objects — madc calls the actual mangled Itanium symbols in your system's libstdc++, not reimplementations -
vector<T>,map<K,V>,set<T>,list<T>with madc-side template instantiation - Real system headers (
<iostream>, etc.) can be consumed directly
- Lambdas with
[&]captures (and GNU nested functions) -
auto, range-basedfor, trailing return types -
namespace/using -
--std=c++NNgates dialect features the same way--std=c89…c23does for C
madc does not claim complete C++. Notable gaps: pure virtual functions,
std::function / unique_ptr and broad <algorithm> coverage, and
wchar_t/wide strings. The north star is C23/C++23 compliance — coverage
grows every release.
- Structs & Classes — the basics: member access, methods
- Functions — multiple returns, function pointers, lambdas
- GCC Compatibility — how compliance is measured
- ← Back to Home