JavaScript

C++’s Slow-Motion Safety Retrofit: Profiles, Lifetimes, Carbon and Cpp2

C++ began in 1979, and its low-level memory semantics still trace back to that era. Meanwhile, regulators and large vendors now treat memory safety as a product requirement. So the language is being retrofitted, but slowly, noisily and in several directions at once.

In this article, we follow that retrofit as of late November 2026. First, we look at why the pressure is real. Next, we separate what actually shipped in C++26 from what did not. Then we run a small experiment on real compilers, and finally we compare the two experiments that sit outside the standard: Carbon and Cpp2.

Why the Pressure Is Real

Google’s numbers explain the urgency. In its 2024 analysis, memory safety issues went from 76% of Android vulnerabilities in 2019 to 24% in 2024, against an industry norm of 70%. A later report put 2025 below 20%. Google credits mainly new code written in memory-safe languages, not rewrites.

Figure 1: Memory safety bugs as a share of vulnerabilities (%)

Google Security Blog (Sept 2024) for 76%, 24% and the 70% industry norm; the 2025 bar is drawn at 20% because the source says only “less than 20%”.

Policy followed the data. The CISA and FBI guidance Product Security Bad Practices says manufacturers of existing memory-unsafe products should have published a memory safety roadmap by January 1, 2026. However, the document is non-binding, and it exempts products whose support ends before 2030.

What Actually Shipped in C++26

The honest answer is: useful pieces, but not a safe language. Two changes remove old foot-guns. Reading an uninitialized local variable is now erroneous behavior instead of undefined behavior, according to Herb Sutter’s trip report. Furthermore, standard library hardening (P3471) adds opt-in precondition checks to containers such as vector and span.

Table 1: Safety items and their C++26 status

ItemPaperStatus
Erroneous behavior for uninitialized readsP2795In C++26
Standard library hardeningP3471In C++26
Contracts (pre, post, contract_assert)n/aIn C++26, but disputed
Safety profilesP3984 and othersNot in C++26; reportedly aimed at C++29
Safe C++ (borrow checker)P3390Discontinued in ISO

Sources: Whole Tomato summary, InfoWorld on Safe C++, and Sutter’s reports. The profiles target is secondary reporting, not a committee promise.

Moreover, the standard itself hit a historic snag. According to Andreas Fertig, the C++26 approval ballot failed on October 23, 2026, mainly over contracts. In response, the committee met in Búzios, kept contracts, and adopted an extension for always-enforced contracts. The vote to reship was 111 in favor, 9 opposed and 8 abstaining, per Sutter’s November report. A second approval ballot is still expected.

Profiles Versus Safe C++

Behind those headlines sits a bigger choice. Safe C++ proposed Rust-style borrow checking and lifetime annotations in a new dialect. Profiles instead promise opt-in guarantees on existing code. The safety working group chose profiles, and the Safe C++ authors confirmed that the proposal was not being continued.

The reasoning was pragmatic. As the C++ Alliance’s Harry Bott told InfoWorld, profiles were an incremental, backward-compatible path, while Safe C++ implied a fundamental redesign. On the other hand, critics such as Sean Baxter argue that profiles have no reliable implementation yet. Both views can be true at once.

Lifetime Annotations: The Pragmatic Middle

Meanwhile, compilers keep moving. Clang’s Lifetime Safety Analysis warns about dangling pointers and uses annotations such as [[clang::lifetimebound]] to follow lifetimes across calls. Importantly, its own documentation says it is designed for bug finding, not verification, so it can miss issues and produce false positives.

To see today’s baseline, we compiled six classic bugs with GCC 13.3 and Clang 18.1 under four setups. Clang 18 predates the new lifetime analysis, so that feature was not tested.

Figure 2: Bugs caught out of six, by tooling setup

Our own test of six small programs (counts a bug as caught if the compiler warned or the run produced a sanitizer, assertion or hardening trap). Toy cases at -O1/-O2 on one Linux machine, so treat them as an illustration, not a benchmark.

Table 2: Which setup caught which bug

BugClang warnClang +hard.Clang +ASanGCC warnGCC +hard.GCC +ASan
Dangling string_viewyesyesyesnonoyes
Returned local referenceyesyesyesyesyesyes
Iterator invalidationnonoyesnonoyes
Out-of-range indexnoyesyesnoyesyes
Uninitialized readyesyesyesnonono
Use after freenonoyesyesyesyes

“warn” means -Wall -Wextra; “+hard.” adds libc++ hardening (Clang) or _GLIBCXX_ASSERTIONS (GCC); “+ASan” adds AddressSanitizer. ASan columns also use -Wall -Wextra.

The pattern is telling. Hardening fixes the spatial bug, and warnings catch some lifetime mistakes. However, iterator invalidation slipped past every compile-time check and only AddressSanitizer saw it at runtime. That gap is exactly what lifetime analysis and profiles try to close. You can reproduce the dangling-view case yourself:

cat > dangle.cpp <<'EOF'
#include <string>
#include <string_view>
#include <cstdio>

std::string make() { return std::string(64, 'x'); }

int main() {
    std::string_view sv = make();
    std::printf("%c\n", sv[0]);
}
EOF
g++ -std=c++20 -g -fsanitize=address dangle.cpp -o dangle
./dangle

On our machine, this ends with an AddressSanitizer heap-use-after-free report. Notice that the program compiles without complaint under GCC 13, because the view outlives its temporary silently.

Carbon and Cpp2: Two Different Bets

Outside ISO, two projects take opposite approaches. Carbon is a successor language. Its roadmap added a memory safety design to its 0.1 milestone, which pushed that milestone to the end of 2026 at the soonest. Its FAQ adds that Carbon is still years away from serious production use, even if the experiment succeeds.

Cpp2, by contrast, is a different kind of experiment. In a July 2026 status note, Sutter calls cppfront a personal experiment, says he cannot support it as a production compiler, and says he now focuses on moving its ideas into ISO C++. One example is bounds checking at call sites by default. Therefore, Cpp2 works more as a laboratory than as a destination.

Checklist: What You Can Do in a C++ Codebase Today

  • Turn on your standard library’s hardening mode in release builds.
  • Run AddressSanitizer in CI, because it caught what warnings missed.
  • Annotate view-returning functions with lifetime attributes where your compiler supports them.
  • Publish a memory safety roadmap if you ship to critical infrastructure.
  • Prefer memory-safe languages for new components, as Google’s data suggests.

What We Have Learned

C++ is being made safer in increments rather than in one leap. C++26 removes some undefined behavior and adds hardening, yet profiles missed the release and Safe C++ was dropped. The standard itself stumbled when its first approval ballot failed over contracts. Our small test showed that no single tool catches everything: hardening handles bounds, warnings catch some lifetime errors, and sanitizers fill the rest at runtime. Meanwhile, Carbon bets on a future successor, and Cpp2 feeds ideas back into ISO C++. For now, Google’s experience suggests that the biggest gains come from putting memory-safe languages in front of new code.

Eleftheria Drosopoulou

Eleftheria is an Experienced Business Analyst with a robust background in the computer software industry. Proficient in Computer Software Training, Digital Marketing, HTML Scripting, and Microsoft Office, they bring a wealth of technical skills to the table. Additionally, she has a love for writing articles on various tech subjects, showcasing a talent for translating complex concepts into accessible content.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Back to top button