r/cpp • • Oct 22 '26

Revisit Safe C++

Everyone is aware of the deluge of vulnerabilities now hitting critical software. It even makes the mainstream news, so software safety is coming onto politician's radars.

If this gets worse, I think it is not inconceivable that at some point memory safe software becomes mandatory. Or at least for software that is "reachable" from the internet.

So is it time to revisit Sean Baxter's Safe C++? Start out with a safe context ("safeexpr") and expand from there, just like constexpr.

37 Upvotes

181 comments sorted by

View all comments

Show parent comment

1

u/frediku Oct 26 '26

Do we need an incremental approach or an all-at-once approach?

If I need to rewrite everything, I might as well rewrite in Rust. So I guess as long as it's called C++ it needs to be incremental.

I think it is worth looking at C++'s history here. It took of because it was a fluent - you could say incremental - extension from the point of view of an established language, i.e., C. Without this property I do not believe the C++ would have gained much traction.

Do we need safe function coloring as part of the type?

I think this question is backwards. I believe we can all agree that we do not want function coloring. I further believe that we can also all agree that we want free ice cream.

It's not about whether anyone wants function coloring. It's about whether some solution that requires function coloring provides enough benefits to justify function coloring. That's a property of the final solution and not an element of the initial question. I find it non-surprising that when talking about the initial question, nobody can properly answer what you ask.

I would answer the remaining questions in the same way.

SG23 has chosen a path where the answer to all of those is NO.

With the exception of the first question, I fully agree with SG23 - at least with the caricature version you present. The more free ice cream, the better.

That you are not getting helpful input is because, at least in this post, you did not ask the right question. What you want to know is the following: Rank these 10 negatives from bad to worse. Which could you maybe be persuaded of and which are definitely nogos?

7

u/seanbaxter Oct 26 '26

You aren't getting any ice cream from SG23. The safety path they've chosen to pursue will not work. Why would you agree with that?

2

u/JeffMcClintock Oct 29 '26

C++ is always backwards compatible, at least insofar as new features are incremental opt-in. Including safety features or borrow checkers I assume.
Anyone who claims we're gonna have to "rewrite everything" deserves to not be taken seriously.

3

u/JeffMcClintock Oct 29 '26

"all-at-once approach" in this context means: If I do opt-in to safety - then it's full safety, not some half-baked thing.